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 f0be68a

Browse files
committed
Moved tests to their own file.
1 parent d860832 commit f0be68a

File tree

2 files changed

+71
-48
lines changed

2 files changed

+71
-48
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/* Copyright 2010-present MongoDB Inc.
2+
*
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*/
15+
16+
using System;
17+
using FluentAssertions;
18+
using Xunit;
19+
20+
namespace MongoDB.Driver.Core.Connections;
21+
22+
public class Socks5AuthenticationSettingsTests
23+
{
24+
[Fact]
25+
public void Socks5AuthenticationSettings_None_should_return_NoAuthenticationSettings_instance()
26+
{
27+
var none = Socks5AuthenticationSettings.None;
28+
none.Should().BeOfType<Socks5AuthenticationSettings.NoAuthenticationSettings>();
29+
}
30+
31+
[Fact]
32+
public void Socks5AuthenticationSettings_UsernamePassword_should_return_UsernamePasswordAuthenticationSettings_instance_with_correct_values()
33+
{
34+
var up = Socks5AuthenticationSettings.UsernamePassword("user", "pass");
35+
up.Should().BeOfType<Socks5AuthenticationSettings.UsernamePasswordAuthenticationSettings>();
36+
var upcast = (Socks5AuthenticationSettings.UsernamePasswordAuthenticationSettings)up;
37+
upcast.Username.Should().Be("user");
38+
upcast.Password.Should().Be("pass");
39+
}
40+
41+
[Theory]
42+
[InlineData(null, "pass")]
43+
[InlineData("user", null)]
44+
[InlineData("", "pass")]
45+
[InlineData("user", "")]
46+
public void Socks5AuthenticationSettings_UsernamePassword_should_throw_when_username_or_password_is_null_or_empty(string username, string password)
47+
{
48+
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword(username, password));
49+
ex.Should().BeAssignableTo<ArgumentException>();
50+
}
51+
52+
[Fact]
53+
public void Socks5AuthenticationSettings_NoAuthenticationSettings_Equals_should_return_true_for_any_Socks5AuthenticationSettings()
54+
{
55+
var none = Socks5AuthenticationSettings.None;
56+
none.Equals(Socks5AuthenticationSettings.None).Should().BeTrue();
57+
none.Equals(Socks5AuthenticationSettings.UsernamePassword("a", "b")).Should().BeFalse();
58+
}
59+
60+
[Fact]
61+
public void Socks5AuthenticationSettings_UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work()
62+
{
63+
var a = Socks5AuthenticationSettings.UsernamePassword("u", "p");
64+
var b = Socks5AuthenticationSettings.UsernamePassword("u", "p");
65+
a.Equals(b).Should().BeTrue();
66+
a.GetHashCode().Should().Be(b.GetHashCode());
67+
var c = Socks5AuthenticationSettings.UsernamePassword("u", "x");
68+
a.Equals(c).Should().BeFalse();
69+
}
70+
}

‎tests/MongoDB.Driver.Tests/Core/Connections/Socks5ProxySettingsTest.cs renamed to ‎tests/MongoDB.Driver.Tests/Core/Connections/Socks5ProxySettingsTests.cs

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace MongoDB.Driver.Core.Connections;
2121

22-
public class Socks5ProxySettingsTest
22+
public class Socks5ProxySettingsTests
2323
{
2424
[Fact]
2525
public void Constructor_should_set_properties_correctly_with_host_only()
@@ -122,51 +122,4 @@ public void Create_should_return_expected_settings()
122122
up.Username.Should().Be("u");
123123
up.Password.Should().Be("p");
124124
}
125-
126-
[Fact]
127-
public void Socks5AuthenticationSettings_None_should_return_NoAuthenticationSettings_instance()
128-
{
129-
var none = Socks5AuthenticationSettings.None;
130-
none.Should().BeOfType<Socks5AuthenticationSettings.NoAuthenticationSettings>();
131-
}
132-
133-
[Fact]
134-
public void Socks5AuthenticationSettings_UsernamePassword_should_return_UsernamePasswordAuthenticationSettings_instance_with_correct_values()
135-
{
136-
var up = Socks5AuthenticationSettings.UsernamePassword("user", "pass");
137-
up.Should().BeOfType<Socks5AuthenticationSettings.UsernamePasswordAuthenticationSettings>();
138-
var upcast = (Socks5AuthenticationSettings.UsernamePasswordAuthenticationSettings)up;
139-
upcast.Username.Should().Be("user");
140-
upcast.Password.Should().Be("pass");
141-
}
142-
143-
[Theory]
144-
[InlineData(null, "pass")]
145-
[InlineData("user", null)]
146-
[InlineData("", "pass")]
147-
[InlineData("user", "")]
148-
public void Socks5AuthenticationSettings_UsernamePassword_should_throw_when_username_or_password_is_null_or_empty(string username, string password)
149-
{
150-
var ex = Record.Exception(() => Socks5AuthenticationSettings.UsernamePassword(username, password));
151-
ex.Should().BeAssignableTo<ArgumentException>();
152-
}
153-
154-
[Fact]
155-
public void Socks5AuthenticationSettings_NoAuthenticationSettings_Equals_should_return_true_for_any_Socks5AuthenticationSettings()
156-
{
157-
var none = Socks5AuthenticationSettings.None;
158-
none.Equals(Socks5AuthenticationSettings.None).Should().BeTrue();
159-
none.Equals(Socks5AuthenticationSettings.UsernamePassword("a", "b")).Should().BeFalse();
160-
}
161-
162-
[Fact]
163-
public void Socks5AuthenticationSettings_UsernamePasswordAuthenticationSettings_Equals_and_GetHashCode_should_work()
164-
{
165-
var a = Socks5AuthenticationSettings.UsernamePassword("u", "p");
166-
var b = Socks5AuthenticationSettings.UsernamePassword("u", "p");
167-
a.Equals(b).Should().BeTrue();
168-
a.GetHashCode().Should().Be(b.GetHashCode());
169-
var c = Socks5AuthenticationSettings.UsernamePassword("u", "x");
170-
a.Equals(c).Should().BeFalse();
171-
}
172125
}

0 commit comments

Comments
(0)

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