Skip to content

Commit b2c4c17

Browse files
committed
Fix formatting issues
1 parent f171ee4 commit b2c4c17

6 files changed

Lines changed: 234 additions & 234 deletions

File tree

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
using FluentValidation;
2-
3-
namespace BuslyCLI.Config.Validators;
4-
5-
public class LearningTransportConfigValidator : AbstractValidator<LearningTransportConfig>
6-
{
7-
public LearningTransportConfigValidator()
8-
{
9-
RuleFor(x => x.StorageDirectory)
10-
.NotEmpty();
11-
}
1+
using FluentValidation;
2+
3+
namespace BuslyCLI.Config.Validators;
4+
5+
public class LearningTransportConfigValidator : AbstractValidator<LearningTransportConfig>
6+
{
7+
public LearningTransportConfigValidator()
8+
{
9+
RuleFor(x => x.StorageDirectory)
10+
.NotEmpty();
11+
}
1212
}
Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using FluentValidation;
2-
3-
namespace BuslyCLI.Config.Validators;
4-
5-
public class RootConfigValidator : AbstractValidator<NServiceBusConfig>
6-
{
7-
public RootConfigValidator()
8-
{
9-
RuleFor(x => x.CurrentTransport).NotEmpty();
10-
11-
RuleFor(x => x.Transports)
12-
.NotEmpty()
13-
.ForEach(x => x.SetValidator(new TransportConfigValidator()));
14-
15-
RuleFor(x => x.CurrentTransport)
16-
.Must((model, currentTransport) =>
17-
model.Transports.Any(t => t.Name == currentTransport))
18-
.WithMessage("current-transport must match one of the defined transports.")
19-
.When(x => x.Transports != null);
20-
21-
}
1+
using FluentValidation;
2+
3+
namespace BuslyCLI.Config.Validators;
4+
5+
public class RootConfigValidator : AbstractValidator<NServiceBusConfig>
6+
{
7+
public RootConfigValidator()
8+
{
9+
RuleFor(x => x.CurrentTransport).NotEmpty();
10+
11+
RuleFor(x => x.Transports)
12+
.NotEmpty()
13+
.ForEach(x => x.SetValidator(new TransportConfigValidator()));
14+
15+
RuleFor(x => x.CurrentTransport)
16+
.Must((model, currentTransport) =>
17+
model.Transports.Any(t => t.Name == currentTransport))
18+
.WithMessage("current-transport must match one of the defined transports.")
19+
.When(x => x.Transports != null);
20+
21+
}
2222
}
Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
using FluentValidation;
2-
3-
namespace BuslyCLI.Config.Validators;
4-
5-
public class TransportConfigValidator : AbstractValidator<TransportConfig>
6-
{
7-
public TransportConfigValidator()
8-
{
9-
RuleFor(x => x.Name).NotEmpty();
10-
11-
RuleFor(x => x.Config)
12-
.NotEmpty()
13-
.WithMessage("Transport must define exactly one transport configuration.");
14-
15-
RuleFor(x => x.LearningTransportConfig)
16-
.SetValidator(new LearningTransportConfigValidator())
17-
.When(x => x.Config is not null);
18-
}
1+
using FluentValidation;
2+
3+
namespace BuslyCLI.Config.Validators;
4+
5+
public class TransportConfigValidator : AbstractValidator<TransportConfig>
6+
{
7+
public TransportConfigValidator()
8+
{
9+
RuleFor(x => x.Name).NotEmpty();
10+
11+
RuleFor(x => x.Config)
12+
.NotEmpty()
13+
.WithMessage("Transport must define exactly one transport configuration.");
14+
15+
RuleFor(x => x.LearningTransportConfig)
16+
.SetValidator(new LearningTransportConfigValidator())
17+
.When(x => x.Config is not null);
18+
}
1919
}
Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
using Bogus;
2-
using BuslyCLI.Config;
3-
using BuslyCLI.Config.Validators;
4-
using FluentValidation.TestHelper;
5-
6-
namespace BuslyCLI.Console.Tests.Config.Validators;
7-
8-
[TestFixture]
9-
public class LearningTransportConfigValidatorTests
10-
{
11-
private readonly LearningTransportConfigValidator _validator;
12-
13-
public LearningTransportConfigValidatorTests()
14-
{
15-
_validator = new LearningTransportConfigValidator();
16-
}
17-
18-
[Test]
19-
public async Task ShouldErrorWhenStorageDirectoryIsNotPassed()
20-
{
21-
// Arrange
22-
var learningTransportConfig = new LearningTransportConfig
23-
{
24-
StorageDirectory = null
25-
};
26-
// Act
27-
var result = await _validator.TestValidateAsync(learningTransportConfig);
28-
29-
// Assert
30-
result.ShouldHaveValidationErrorFor(c => c.StorageDirectory)
31-
.WithErrorMessage("'Storage Directory' must not be empty.");
32-
}
33-
34-
[Test]
35-
public async Task ShouldNotErrorStorageDirectoryIsPassed()
36-
{
37-
// Arrange
38-
var learningTransportConfig = new LearningTransportConfig
39-
{
40-
StorageDirectory = new Faker().System.DirectoryPath()
41-
};
42-
// Act
43-
var result = await _validator.TestValidateAsync(learningTransportConfig);
44-
45-
// Assert
46-
result.ShouldNotHaveValidationErrorFor(c => c.StorageDirectory);
47-
}
1+
using Bogus;
2+
using BuslyCLI.Config;
3+
using BuslyCLI.Config.Validators;
4+
using FluentValidation.TestHelper;
5+
6+
namespace BuslyCLI.Console.Tests.Config.Validators;
7+
8+
[TestFixture]
9+
public class LearningTransportConfigValidatorTests
10+
{
11+
private readonly LearningTransportConfigValidator _validator;
12+
13+
public LearningTransportConfigValidatorTests()
14+
{
15+
_validator = new LearningTransportConfigValidator();
16+
}
17+
18+
[Test]
19+
public async Task ShouldErrorWhenStorageDirectoryIsNotPassed()
20+
{
21+
// Arrange
22+
var learningTransportConfig = new LearningTransportConfig
23+
{
24+
StorageDirectory = null
25+
};
26+
// Act
27+
var result = await _validator.TestValidateAsync(learningTransportConfig);
28+
29+
// Assert
30+
result.ShouldHaveValidationErrorFor(c => c.StorageDirectory)
31+
.WithErrorMessage("'Storage Directory' must not be empty.");
32+
}
33+
34+
[Test]
35+
public async Task ShouldNotErrorStorageDirectoryIsPassed()
36+
{
37+
// Arrange
38+
var learningTransportConfig = new LearningTransportConfig
39+
{
40+
StorageDirectory = new Faker().System.DirectoryPath()
41+
};
42+
// Act
43+
var result = await _validator.TestValidateAsync(learningTransportConfig);
44+
45+
// Assert
46+
result.ShouldNotHaveValidationErrorFor(c => c.StorageDirectory);
47+
}
4848
}
Lines changed: 90 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
1-
using BuslyCLI.Config;
2-
using BuslyCLI.Config.Validators;
3-
using FluentValidation.TestHelper;
4-
5-
namespace BuslyCLI.Console.Tests.Config.Validators;
6-
7-
[TestFixture]
8-
public class RootConfigValidatorTests
9-
{
10-
private readonly RootConfigValidator _validator;
11-
12-
public RootConfigValidatorTests()
13-
{
14-
_validator = new RootConfigValidator();
15-
}
16-
17-
[Test]
18-
public void ShouldNotErrorWhenCurrentTransportIsDefined()
19-
{
20-
// Arrange
21-
var config = new NServiceBusConfig
22-
{
23-
CurrentTransport = "local-learning",
24-
};
25-
26-
// Act
27-
var result = _validator.TestValidate(config);
28-
29-
// Assert
30-
result.ShouldNotHaveValidationErrorFor(x => x.CurrentTransport);
31-
}
32-
33-
34-
[Test]
35-
public void ShouldErrorWhenCurrentTransportIsNotDefined()
36-
{
37-
// Arrange
38-
var config = new NServiceBusConfig
39-
{
40-
CurrentTransport = "",
41-
};
42-
43-
// Act
44-
var result = _validator.TestValidate(config);
45-
46-
// Assert
47-
result.ShouldHaveValidationErrorFor(c => c.CurrentTransport)
48-
.WithErrorMessage("'Current Transport' must not be empty.");
49-
}
50-
51-
[Test]
52-
public void ShouldErrorWhenCurrentTransportDoesntMatchAnyConfiguredTransports()
53-
{
54-
// Arrange
55-
var config = new NServiceBusConfig
56-
{
57-
CurrentTransport = "d",
58-
Transports = new List<TransportConfig>()
59-
{
60-
new TransportConfig { Name = "a" },
61-
new TransportConfig { Name = "b" }
62-
}
63-
};
64-
65-
// Act
66-
var result = _validator.TestValidate(config);
67-
68-
// Assert
69-
result.ShouldHaveValidationErrorFor(c => c.CurrentTransport)
70-
.WithErrorMessage("current-transport must match one of the defined transports.");
71-
}
72-
73-
74-
[Test]
75-
public void ShouldErrorWhenTransportsArrayIsEmpty()
76-
{
77-
// Arrange
78-
var config = new NServiceBusConfig
79-
{
80-
CurrentTransport = "d",
81-
};
82-
83-
// Act
84-
var result = _validator.TestValidate(config);
85-
86-
// Assert
87-
result.ShouldHaveValidationErrorFor(c => c.Transports)
88-
.WithErrorMessage("'Transports' must not be empty.");
89-
}
90-
1+
using BuslyCLI.Config;
2+
using BuslyCLI.Config.Validators;
3+
using FluentValidation.TestHelper;
4+
5+
namespace BuslyCLI.Console.Tests.Config.Validators;
6+
7+
[TestFixture]
8+
public class RootConfigValidatorTests
9+
{
10+
private readonly RootConfigValidator _validator;
11+
12+
public RootConfigValidatorTests()
13+
{
14+
_validator = new RootConfigValidator();
15+
}
16+
17+
[Test]
18+
public void ShouldNotErrorWhenCurrentTransportIsDefined()
19+
{
20+
// Arrange
21+
var config = new NServiceBusConfig
22+
{
23+
CurrentTransport = "local-learning",
24+
};
25+
26+
// Act
27+
var result = _validator.TestValidate(config);
28+
29+
// Assert
30+
result.ShouldNotHaveValidationErrorFor(x => x.CurrentTransport);
31+
}
32+
33+
34+
[Test]
35+
public void ShouldErrorWhenCurrentTransportIsNotDefined()
36+
{
37+
// Arrange
38+
var config = new NServiceBusConfig
39+
{
40+
CurrentTransport = "",
41+
};
42+
43+
// Act
44+
var result = _validator.TestValidate(config);
45+
46+
// Assert
47+
result.ShouldHaveValidationErrorFor(c => c.CurrentTransport)
48+
.WithErrorMessage("'Current Transport' must not be empty.");
49+
}
50+
51+
[Test]
52+
public void ShouldErrorWhenCurrentTransportDoesntMatchAnyConfiguredTransports()
53+
{
54+
// Arrange
55+
var config = new NServiceBusConfig
56+
{
57+
CurrentTransport = "d",
58+
Transports = new List<TransportConfig>()
59+
{
60+
new TransportConfig { Name = "a" },
61+
new TransportConfig { Name = "b" }
62+
}
63+
};
64+
65+
// Act
66+
var result = _validator.TestValidate(config);
67+
68+
// Assert
69+
result.ShouldHaveValidationErrorFor(c => c.CurrentTransport)
70+
.WithErrorMessage("current-transport must match one of the defined transports.");
71+
}
72+
73+
74+
[Test]
75+
public void ShouldErrorWhenTransportsArrayIsEmpty()
76+
{
77+
// Arrange
78+
var config = new NServiceBusConfig
79+
{
80+
CurrentTransport = "d",
81+
};
82+
83+
// Act
84+
var result = _validator.TestValidate(config);
85+
86+
// Assert
87+
result.ShouldHaveValidationErrorFor(c => c.Transports)
88+
.WithErrorMessage("'Transports' must not be empty.");
89+
}
90+
9191
}

0 commit comments

Comments
 (0)