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 654c59d

Browse files
committed
Corrected order and parameter name.
1 parent 5ddba6d commit 654c59d

File tree

2 files changed

+27
-21
lines changed

2 files changed

+27
-21
lines changed

‎src/MongoDB.Driver/Core/Connections/Socks5AuthenticationSettings.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ internal sealed class UsernamePasswordAuthenticationSettings : Socks5Authenticat
6868
internal UsernamePasswordAuthenticationSettings(string username, string password)
6969
{
7070
Username = Ensure.IsNotNullOrEmpty(username, nameof(username));
71-
Ensure.That(Encoding.UTF8.GetByteCount(username) <= byte.MaxValue, $"{nameof(username)} must be at most 255 bytes long when encoded as UTF-8");
71+
Ensure.That(Encoding.UTF8.GetByteCount(username) <= byte.MaxValue, $"{nameof(username)} must be at most 255 bytes long when encoded as UTF-8",nameof(username));
7272
Password = Ensure.IsNotNullOrEmpty(password, nameof(password));
73-
Ensure.That(Encoding.UTF8.GetByteCount(password) <= byte.MaxValue, $"{nameof(password)} must be at most 255 bytes long when encoded as UTF-8");
73+
Ensure.That(Encoding.UTF8.GetByteCount(password) <= byte.MaxValue, $"{nameof(password)} must be at most 255 bytes long when encoded as UTF-8",nameof(password));
7474
}
7575

7676
/// <inheritdoc />

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,16 @@ public void UsernamePassword_should_return_UsernamePasswordAuthenticationSetting
4747
public void UsernamePassword_should_throw_when_username_is_null_or_empty(string username)
4848
{
4949
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword(username, "pass"));
50-
ex.Should().BeAssignableTo<ArgumentException>();
51-
ex.Message.Should().Contain("username");
50+
var argumentEx = ex.Should().BeAssignableTo<ArgumentException>().Subject;
51+
argumentEx.ParamName.Should().Contain("username");
52+
}
53+
54+
[Fact]
55+
public void UsernamePassword_should_throw_when_username_is_too_long()
56+
{
57+
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword(TooLong, "password"));
58+
var argumentEx = ex.Should().BeAssignableTo<ArgumentException>().Subject;
59+
argumentEx.ParamName.Should().Contain("username");
5260
}
5361

5462
[Theory]
@@ -57,24 +65,16 @@ public void UsernamePassword_should_throw_when_username_is_null_or_empty(string
5765
public void UsernamePassword_should_throw_when_password_is_null_or_empty(string password)
5866
{
5967
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword("username", password));
60-
ex.Should().BeAssignableTo<ArgumentException>();
61-
ex.Message.Should().Contain("password");
62-
}
63-
64-
[Fact]
65-
public void UsernamePassword_should_throw_when_username_is_too_long()
66-
{
67-
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword(TooLong, "password"));
68-
ex.Should().BeAssignableTo<ArgumentException>();
69-
ex.Message.Should().Contain("username");
68+
var argumentEx = ex.Should().BeAssignableTo<ArgumentException>().Subject;
69+
argumentEx.ParamName.Should().Contain("password");
7070
}
7171

7272
[Fact]
7373
public void UsernamePassword_should_throw_when_password_is_too_long()
7474
{
7575
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword("username", TooLong));
76-
ex.Should().BeAssignableTo<ArgumentException>();
77-
ex.Message.Should().Contain("password");
76+
varargumentEx=ex.Should().BeAssignableTo<ArgumentException>().Subject;
77+
argumentEx.ParamName.Should().Contain("password");
7878
}
7979

8080
[Fact]
@@ -93,16 +93,22 @@ public void NoAuthenticationSettings_Equals_and_GetHashCode_should_work_correctl
9393
[InlineData("u", "p", "u", "p", true)]
9494
[InlineData("u", "p", "u", "x", false)]
9595
[InlineData("u", "p", "x", "p", false)]
96-
public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly(string u1, string p1, string u2, string p2, bool areEqual)
96+
public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly_with_UsernamePassword(string u1, string p1, string u2, string p2, bool areEqual)
9797
{
9898
var up1 = Socks5AuthenticationSettings.UsernamePassword(u1, p1);
9999

100-
var none = Socks5AuthenticationSettings.None;
101-
up1.Equals(none).Should().BeFalse();
102-
up1.GetHashCode().Should().NotBe(none.GetHashCode());
103-
104100
var up2 = Socks5AuthenticationSettings.UsernamePassword(u2, p2);
105101
up1.Equals(up2).Should().Be(areEqual);
106102
up1.GetHashCode().Equals(up2.GetHashCode()).Should().Be(areEqual);
107103
}
104+
105+
[Fact]
106+
public void UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work_correctly_with_None()
107+
{
108+
var up1 = Socks5AuthenticationSettings.UsernamePassword("u1", "p1");
109+
110+
var none = Socks5AuthenticationSettings.None;
111+
up1.Equals(none).Should().BeFalse();
112+
up1.GetHashCode().Should().NotBe(none.GetHashCode());
113+
}
108114
}

0 commit comments

Comments
(0)

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