@@ -22,7 +22,7 @@ namespace MongoDB.Driver.Core.Connections;
22
22
public class Socks5AuthenticationSettingsTests
23
23
{
24
24
// 3 bytes * 86 = 258 bytes length when UTF8 encoded
25
- public const string TooLong =
25
+ private const string TooLong =
26
26
"€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€" ;
27
27
28
28
[ Fact ]
@@ -36,8 +36,7 @@ public void None_should_return_NoAuthenticationSettings_instance()
36
36
public void UsernamePassword_should_return_UsernamePasswordAuthenticationSettings_instance_with_correct_values ( )
37
37
{
38
38
var up = Socks5AuthenticationSettings . UsernamePassword ( "user" , "pass" ) ;
39
- up . Should ( ) . BeOfType < Socks5AuthenticationSettings . UsernamePasswordAuthenticationSettings > ( ) ;
40
- var upcast = ( Socks5AuthenticationSettings . UsernamePasswordAuthenticationSettings ) up ;
39
+ var upcast = up . Should ( ) . BeOfType < Socks5AuthenticationSettings . UsernamePasswordAuthenticationSettings > ( ) . Subject ;
41
40
upcast . Username . Should ( ) . Be ( "user" ) ;
42
41
upcast . Password . Should ( ) . Be ( "pass" ) ;
43
42
}
@@ -63,21 +62,32 @@ public void UsernamePassword_should_throw_when_username_or_password_are_too_long
63
62
}
64
63
65
64
[ Fact ]
66
- public void NoAuthenticationSettings_Equals_should_return_true_for_any_Socks5AuthenticationSettings ( )
65
+ public void NoAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly ( )
67
66
{
68
67
var none = Socks5AuthenticationSettings . None ;
69
68
none . Equals ( Socks5AuthenticationSettings . None ) . Should ( ) . BeTrue ( ) ;
70
- none . Equals ( Socks5AuthenticationSettings . UsernamePassword ( "a" , "b" ) ) . Should ( ) . BeFalse ( ) ;
69
+ none . GetHashCode ( ) . Should ( ) . Be ( Socks5AuthenticationSettings . None . GetHashCode ( ) ) ;
70
+
71
+ var up = Socks5AuthenticationSettings . UsernamePassword ( "a" , "b" ) ;
72
+ none . Equals ( up ) . Should ( ) . BeFalse ( ) ;
73
+ none . GetHashCode ( ) . Should ( ) . NotBe ( up . GetHashCode ( ) ) ;
71
74
}
72
75
73
76
[ Fact ]
74
- public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work ( )
77
+ public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly ( )
75
78
{
76
- var a = Socks5AuthenticationSettings . UsernamePassword ( "u" , "p" ) ;
77
- var b = Socks5AuthenticationSettings . UsernamePassword ( "u" , "p" ) ;
78
- a . Equals ( b ) . Should ( ) . BeTrue ( ) ;
79
- a . GetHashCode ( ) . Should ( ) . Be ( b . GetHashCode ( ) ) ;
80
- var c = Socks5AuthenticationSettings . UsernamePassword ( "u" , "x" ) ;
81
- a . Equals ( c ) . Should ( ) . BeFalse ( ) ;
79
+ var up1 = Socks5AuthenticationSettings . UsernamePassword ( "u" , "p" ) ;
80
+
81
+ var none = Socks5AuthenticationSettings . None ;
82
+ up1 . Equals ( none ) . Should ( ) . BeFalse ( ) ;
83
+ up1 . GetHashCode ( ) . Should ( ) . NotBe ( none . GetHashCode ( ) ) ;
84
+
85
+ var up2 = Socks5AuthenticationSettings . UsernamePassword ( "u" , "p" ) ;
86
+ up1 . Equals ( up2 ) . Should ( ) . BeTrue ( ) ;
87
+ up1 . GetHashCode ( ) . Should ( ) . Be ( up2 . GetHashCode ( ) ) ;
88
+
89
+ var up3 = Socks5AuthenticationSettings . UsernamePassword ( "u" , "x" ) ;
90
+ up1 . Equals ( up3 ) . Should ( ) . BeFalse ( ) ;
91
+ up1 . GetHashCode ( ) . Should ( ) . NotBe ( up3 . GetHashCode ( ) ) ;
82
92
}
83
93
}
0 commit comments