Esempio n. 1
0
        public void Start()
        {
            if (!Conventions.Any())
            {
                throw new InvalidOperationException(
                          $"There are no {nameof(IRegistrationConvention)}'s in this scanning operation. ");
            }

            TypeFinder = TypeRepository.FindTypes(_assemblies, type => _filter.Matches(type));
        }
        public void Should_not_add_any_convention_and_return_ViolationHandlerExpression_of_T()
        {
            // Arrange
            var conventions = new Conventions();
            var expression  = new ViolationConfigurationExpression(conventions);

            // Act
            var result = expression.Of <IgnorePolicy>();

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(conventions.Any(), Is.False);
        }
        public void Should_not_remove_conventions_not_matching_predicate()
        {
            // Arrange
            var conventions = new Conventions {
                new MockConvention()
            };
            var expression = new ViolationConfigurationExpression(conventions);

            // Act
            expression.RemoveConventions(c => c is NonMatchingConvention);

            // Assert
            Assert.That(conventions.Any(), Is.True);
        }
        public void Should_remove_conventions_matching_type()
        {
            // Arrange
            var conventions = new Conventions {
                new MockConvention()
            };
            var expression = new ViolationConfigurationExpression(conventions);

            // Act
            expression.RemoveConventions <MockConvention>();

            // Assert
            Assert.That(conventions.Any(), Is.False);
        }
        public void Should_not_add_any_convention_and_return_ViolationHandlerExpression_with_predicate()
        {
            // Arrange
            Func <PolicyResult, bool> expectedPredicate = pr => pr.PolicyType == typeof(IgnorePolicy);
            var conventions = new Conventions();
            var expression  = new ViolationConfigurationExpression(conventions);

            // Act
            var result = expression.Of(expectedPredicate);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result.Predicate, Is.EqualTo(expectedPredicate));
            Assert.That(conventions.Any(), Is.False);
        }