This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +50
-0
lines changed
GitHub.Exports/Primitives Expand file tree Collapse file tree 3 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,16 @@ public static bool IsGitHubDotComUri(Uri hostUri)
7878 || hostUri . IsSameHost ( gistUri ) ;
7979 }
8080
81+ public static bool operator == ( HostAddress a , HostAddress b )
82+ {
83+ return object . ReferenceEquals ( a , null ) ? object . ReferenceEquals ( b , null ) : a . Equals ( b ) ;
84+ }
85+
86+ public static bool operator != ( HostAddress a , HostAddress b )
87+ {
88+ return ! ( a == b ) ;
89+ }
90+
8191 public bool IsGitHubDotCom ( )
8292 {
8393 return IsGitHubDotComUri ( ApiUri ) ;
Original file line number Diff line number Diff line change 1+ using System ;
2+ using GitHub . Primitives ;
3+ using Xunit ;
4+
5+ namespace UnitTests . GitHub . Exports
6+ {
7+ public class HostAddressTests
8+ {
9+ [ Fact ]
10+ public void ShouldBeEqualIfAddressesMatch ( )
11+ {
12+ var address1 = HostAddress . Create ( "foo.com" ) ;
13+ var address2 = HostAddress . Create ( "foo.com" ) ;
14+ var null1 = default ( HostAddress ) ;
15+ var null2 = default ( HostAddress ) ;
16+
17+ Assert . True ( address1 . Equals ( address2 ) ) ;
18+ Assert . True ( address1 == address2 ) ;
19+ Assert . False ( address1 != address2 ) ;
20+ Assert . True ( null1 == null2 ) ;
21+ }
22+
23+ [ Fact ]
24+ public void ShouldBeNotEqualIfAddressesDontMatch ( )
25+ {
26+ var address1 = HostAddress . Create ( "foo.com" ) ;
27+ var address2 = HostAddress . Create ( "bar.com" ) ;
28+ var null1 = default ( HostAddress ) ;
29+
30+ Assert . False ( address1 . Equals ( address2 ) ) ;
31+ Assert . False ( address1 == address2 ) ;
32+ Assert . True ( address1 != address2 ) ;
33+ Assert . False ( null1 == address1 ) ;
34+ Assert . False ( address1 == null1 ) ;
35+ Assert . True ( null1 != address1 ) ;
36+ Assert . True ( address1 != null1 ) ;
37+ }
38+ }
39+ }
Original file line number Diff line number Diff line change 181181 <Compile Include =" GitHub.Exports.Reactive\Caches\AccountCacheItemTests.cs" />
182182 <Compile Include =" GitHub.Exports\GitServiceTests.cs" />
183183 <None Include =" GitHub.Exports\VSServicesTests.cs" />
184+ <Compile Include =" GitHub.Exports\HostAddressTests.cs" />
184185 <Compile Include =" GitHub.Exports\LocalRepositoryModelTests.cs" />
185186 <Compile Include =" GitHub.Extensions\GuardTests.cs" />
186187 <Compile Include =" GitHub.Extensions\UriExtensionTests.cs" />
You can’t perform that action at this time.
0 commit comments