Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Commit 86a5c05

Browse files
committed
Add test
1 parent 1ba096f commit 86a5c05

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/Microsoft.AspNetCore.Http.Abstractions/PathString.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,7 @@ public static implicit operator PathString(string s)
450450
/// </summary>
451451
/// <param name="path"></param>
452452
public static implicit operator string(PathString path)
453-
{
454-
return path.ToString();
455-
}
453+
=> path.ToString();
456454

457455
internal static PathString ConvertFromString(string s)
458456
=> string.IsNullOrEmpty(s) ? new PathString(s) : FromUriComponent(s);

test/Microsoft.AspNetCore.Http.Abstractions.Tests/PathStringTests.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -221,5 +221,15 @@ public void PathStringConvertsOnlyToAndFromString()
221221
Assert.False(converter.CanConvertTo(typeof(int)));
222222
Assert.False(converter.CanConvertTo(typeof(bool)));
223223
}
224+
225+
[Fact]
226+
public void PathStringStaysEqualAfterAssignments()
227+
{
228+
PathString p1 = "/?";
229+
string s1 = p1; // Becomes "/%3F"
230+
PathString p2 = s1; // Stays "/%3F"
231+
Assert.Equal(p1, p2);
232+
}
233+
224234
}
225235
}

0 commit comments

Comments
 (0)