-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPostgreSqlTransportConfigValidatorTests.cs
More file actions
47 lines (40 loc) · 1.37 KB
/
PostgreSqlTransportConfigValidatorTests.cs
File metadata and controls
47 lines (40 loc) · 1.37 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;
using BuslyCLI.Config.Validators;
using FluentValidation.TestHelper;
namespace BuslyCLI.Console.Tests.Config.Validators;
[TestFixture]
public class PostgreSqlTransportConfigValidatorTests
{
private readonly PostgreSqlTransportConfigValidator _validator;
public PostgreSqlTransportConfigValidatorTests()
{
_validator = new PostgreSqlTransportConfigValidator();
}
[Test]
public async Task ShouldErrorWhenConnectionStringIsNotPassed()
{
// Arrange
var postgreSqlTransportConfig = new PostgreSqlTransportConfig
{
ConnectionString = null
};
// Act
var result = await _validator.TestValidateAsync(postgreSqlTransportConfig);
// Assert
result.ShouldHaveValidationErrorFor(c => c.ConnectionString)
.WithErrorMessage("'Connection String' must not be empty.");
}
[Test]
public async Task ShouldNotErrorConnectionStringIsPassed()
{
// Arrange
var postgreSqlTransportConfig = new PostgreSqlTransportConfig
{
ConnectionString = "Host=localhost;Database=ordering;Username=postgres;Password=password"
};
// Act
var result = await _validator.TestValidateAsync(postgreSqlTransportConfig);
// Assert
result.ShouldNotHaveValidationErrorFor(c => c.ConnectionString);
}
}