Esempio n. 1
0
        public void ValidateConstruction_WhenModelHasNullProviderResultsRepositoryPolicy_ShouldShouldBeInvalid()
        {
            // Arrange
            CalculatorResiliencePolicies model = new CalculatorResiliencePolicies()
            {
                CalculationsRepository           = Policy.NoOpAsync(),
                ProviderResultsRepository        = null,
                ProviderSourceDatasetsRepository = Policy.NoOpAsync(),
                CacheProvider = Policy.NoOpAsync(),
                Messenger     = Policy.NoOpAsync()
            };
            CalculatorResiliencePoliciesValidator validator = new CalculatorResiliencePoliciesValidator();

            // Act
            ValidationResult result = validator.Validate(model);

            // Assert
            result
            .IsValid
            .Should()
            .BeFalse();

            result
            .Errors
            .Count
            .Should().Be(1);

            result
            .Errors[0]
            .ErrorMessage
            .Should().Contain("ProviderResultsRepository");
        }
Esempio n. 2
0
        public void ValidateConstruction_WhenModelIsValid_ResultShouldBeValid()
        {
            // Arrange
            CalculatorResiliencePolicies model = new CalculatorResiliencePolicies()
            {
                CalculationsRepository           = Policy.NoOpAsync(),
                ProviderResultsRepository        = Policy.NoOpAsync(),
                ProviderSourceDatasetsRepository = Policy.NoOpAsync(),
                CacheProvider = Policy.NoOpAsync(),
                Messenger     = Policy.NoOpAsync()
            };
            CalculatorResiliencePoliciesValidator validator = new CalculatorResiliencePoliciesValidator();

            // Act
            ValidationResult result = validator.Validate(model);

            // Assert
            result
            .IsValid
            .Should()
            .BeTrue();
        }