Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e39fa0f

Browse files
committed
Small fixes to tests
1 parent 6c72f58 commit e39fa0f

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

‎tests/MongoDB.Driver.Tests/Core/Connections/Socks5AuthenticationSettingsTests.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace MongoDB.Driver.Core.Connections;
2222
public class Socks5AuthenticationSettingsTests
2323
{
2424
// 3 bytes * 86 = 258 bytes length when UTF8 encoded
25-
public const string TooLong =
25+
private const string TooLong =
2626
"€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€€";
2727

2828
[Fact]
@@ -36,8 +36,7 @@ public void None_should_return_NoAuthenticationSettings_instance()
3636
public void UsernamePassword_should_return_UsernamePasswordAuthenticationSettings_instance_with_correct_values()
3737
{
3838
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;
4140
upcast.Username.Should().Be("user");
4241
upcast.Password.Should().Be("pass");
4342
}
@@ -63,21 +62,32 @@ public void UsernamePassword_should_throw_when_username_or_password_are_too_long
6362
}
6463

6564
[Fact]
66-
public void NoAuthenticationSettings_Equals_should_return_true_for_any_Socks5AuthenticationSettings()
65+
public void NoAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly()
6766
{
6867
var none = Socks5AuthenticationSettings.None;
6968
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());
7174
}
7275

7376
[Fact]
74-
public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work()
77+
public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly()
7578
{
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());
8292
}
8393
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /