Beispiel #1
0
        public void ToStringDoesNotReturnTypeName()
        {
            var sut = new ExpressionExecuteOrderRule <Person>(x => x.FirstName, Environment.TickCount);

            var actual = sut.ToString();

            actual.Should().NotBe(sut.GetType().ToString());
        }
Beispiel #2
0
        public void PriorityReturnsConstructorValue()
        {
            var priority = Environment.TickCount;

            var sut = new ExpressionExecuteOrderRule <Person>(x => x.LastName, priority);

            sut.Priority.Should().Be(priority);
        }
Beispiel #3
0
        public void IsMatchThrowsExceptionWithNullProperty()
        {
            var priority = Environment.TickCount;

            var sut = new ExpressionExecuteOrderRule <Person>(x => x.FirstName, priority);

            Action action = () => sut.IsMatch((PropertyInfo)null !);

            action.Should().Throw <ArgumentNullException>();
        }
Beispiel #4
0
        public void IsMatchReturnsTrueWhenPropertyMatchesBaseTypeProperty()
        {
            var priority = Environment.TickCount;
            var property = typeof(Entity).GetProperty(nameof(Entity.Id)) !;

            var sut = new ExpressionExecuteOrderRule <Person>(x => x.Id, priority);

            var actual = sut.IsMatch(property);

            actual.Should().BeTrue();
        }
Beispiel #5
0
        public void IsMatchReturnsTrueWhenInheritedPropertyMatchesPropertyOnDeclaredType()
        {
            var priority = Environment.TickCount;
            var property = typeof(Person).GetProperty(nameof(Person.Id)) !;

            var sut = new ExpressionExecuteOrderRule <Person>(x => x.Id, priority);

            var actual = sut.IsMatch(property);

            actual.Should().BeTrue();
        }
Beispiel #6
0
        public void IsMatchReturnsFalseWhenPropertyNameDoesNotMatch()
        {
            var priority = Environment.TickCount;
            var property = typeof(Person).GetProperty(nameof(Person.FirstName)) !;

            var sut = new ExpressionExecuteOrderRule <Person>(x => x.LastName, priority);

            var actual = sut.IsMatch(property);

            actual.Should().BeFalse();
        }
Beispiel #7
0
        public void IsMatchReturnsFalseForParameter()
        {
            var priority      = Environment.TickCount;
            var parameterInfo = typeof(Person).GetConstructors()
                                .First(x => x.GetParameters().FirstOrDefault()?.Name == "firstName").GetParameters().First();

            var sut = new ExpressionExecuteOrderRule <Simple>(x => x.LastName, priority);

            var actual = sut.IsMatch(parameterInfo);

            actual.Should().BeFalse();
        }
Beispiel #8
0
        public static IBuildConfiguration AddExecuteOrderRule <T>(
            this IBuildConfiguration configuration,
            Expression <Func <T, object?> > expression,
            int priority)
        {
            configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));

            expression = expression ?? throw new ArgumentNullException(nameof(expression));

            var rule = new ExpressionExecuteOrderRule <T>(expression, priority);

            configuration.ExecuteOrderRules.Add(rule);

            return(configuration);
        }