-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSqlServerTransportConfigValidatorTests.cs
More file actions
47 lines (40 loc) · 1.43 KB
/
SqlServerTransportConfigValidatorTests.cs
File metadata and controls
47 lines (40 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using BuslyCLI.Config.Transports;
using BuslyCLI.Config.Validators;
using FluentValidation.TestHelper;
namespace BuslyCLI.Console.Tests.Config.Validators;
[TestFixture]
public class SqlServerTransportConfigValidatorTests
{
private readonly SqlServerTransportConfigValidator _validator;
public SqlServerTransportConfigValidatorTests()
{
_validator = new SqlServerTransportConfigValidator();
}
[Test]
public async Task ShouldErrorWhenConnectionStringIsNotPassed()
{
// Arrange
var sqlServerTransportConfig = new SqlServerTransportConfig
{
ConnectionString = null
};
// Act
var result = await _validator.TestValidateAsync(sqlServerTransportConfig);
// Assert
result.ShouldHaveValidationErrorFor(c => c.ConnectionString)
.WithErrorMessage("'Connection String' must not be empty.");
}
[Test]
public async Task ShouldNotErrorConnectionStringIsPassed()
{
// Arrange
var sqlServerTransportConfig = new SqlServerTransportConfig
{
ConnectionString = "Data Source=(local);Initial Catalog=Ordering;Integrated Security=SSPI;Application Name=Busly-CLI;TrustServerCertificate=true"
};
// Act
var result = await _validator.TestValidateAsync(sqlServerTransportConfig);
// Assert
result.ShouldNotHaveValidationErrorFor(c => c.ConnectionString);
}
}