Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit cb03ede

Browse files
committed
Some more comparison tests
1 parent 581be48 commit cb03ede

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/GitHub.Exports/Primitives/HostAddress.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public string Title
9090

9191
public override int GetHashCode()
9292
{
93-
return WebUri?.GetHashCode() ?? 0 ^ ApiUri?.GetHashCode() ?? 0;
93+
return (WebUri?.GetHashCode() ?? 0) ^ (ApiUri?.GetHashCode() ?? 0);
9494
}
9595

9696
public override bool Equals(object obj)

src/UnitTests/GitHub.App/Models/RepositoryModelTests.cs renamed to src/UnitTests/GitHub.App/Models/ComparisonTests.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
using UnitTests;
1010
using Xunit;
1111

12-
public class RepositoryModelTests
12+
public class ComparisonTests
1313
{
14-
public class ComparisonTests : TestBaseClass
14+
public class RepositoryModelTests : TestBaseClass
1515
{
1616
[Theory]
1717
[InlineData("a name", "https://github.com/github/VisualStudio", null, "a name", "https://github.com/github/VisualStudio", null)]
@@ -54,4 +54,18 @@ public void DifferentContentEqualsFalse(string name1, string url1, string name2,
5454
Assert.NotEqual(a.GetHashCode(), b.GetHashCode());
5555
}
5656
}
57+
58+
public class HostAddressTests : TestBaseClass
59+
{
60+
[Theory]
61+
[InlineData("https://github.com/owner/repo")]
62+
[InlineData("https://anotherurl.com/foo/bar")]
63+
public void SameContentEqualsTrue(string url)
64+
{
65+
var a = HostAddress.Create(url);
66+
var b = HostAddress.Create(url);
67+
Assert.Equal(a, b);
68+
Assert.Equal(a.GetHashCode(), b.GetHashCode());
69+
}
70+
}
5771
}

src/UnitTests/UnitTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
<Compile Include="GitHub.App\Models\ModelServiceTests.cs" />
146146
<Compile Include="GitHub.App\Controllers\UIControllerTests.cs" />
147147
<Compile Include="GitHub.App\Models\RepositoryHostTests.cs" />
148-
<Compile Include="GitHub.App\Models\RepositoryModelTests.cs" />
148+
<Compile Include="GitHub.App\Models\ComparisonTests.cs" />
149149
<Compile Include="GitHub.App\Services\AvatarProviderTests.cs" />
150150
<Compile Include="GitHub.App\Services\GitClientTests.cs" />
151151
<Compile Include="GitHub.App\Services\RepositoryCloneServiceTests.cs" />

0 commit comments

Comments
 (0)