This repository was archived by the owner on Jun 21, 2023. It is now read-only.
File tree 3 files changed +50
-0
lines changed
GitHub.Exports/Primitives
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)
78
78
|| hostUri . IsSameHost ( gistUri ) ;
79
79
}
80
80
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
+
81
91
public bool IsGitHubDotCom ( )
82
92
{
83
93
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 181
181
<Compile Include =" GitHub.Exports.Reactive\Caches\AccountCacheItemTests.cs" />
182
182
<Compile Include =" GitHub.Exports\GitServiceTests.cs" />
183
183
<None Include =" GitHub.Exports\VSServicesTests.cs" />
184
+ <Compile Include =" GitHub.Exports\HostAddressTests.cs" />
184
185
<Compile Include =" GitHub.Exports\LocalRepositoryModelTests.cs" />
185
186
<Compile Include =" GitHub.Extensions\GuardTests.cs" />
186
187
<Compile Include =" GitHub.Extensions\UriExtensionTests.cs" />
You can’t perform that action at this time.
0 commit comments