Exemple #1
0
        public void QueryPropertiesWorksInIsolation()
        {
            var result = UserQuery.BuildQuery(new TestUserSearch {
                Keyword = "m"
            });

            result.Should().HaveCount(2);
            result.All(x => x.Age == 20).Should().BeTrue();
        }
Exemple #2
0
        public void QueryPropertyWorksInIsolation()
        {
            var result = UserQuery.BuildQuery(new TestUserSearch {
                Age = 20
            });

            result.Should().HaveCount(2);
            result.All(x => x.Age == 20).Should().BeTrue();
            result.Any(x => x.Age != 20).Should().BeFalse();
        }
Exemple #3
0
        public void ThrowsException_WhenPropertyDoesntExist_DefaultAttributeConstructor()
        {
            Action a = () => UserQuery.BuildQuery(new TestSearchWithInvalidPropertyName {
                Ages = 10
            }, x => new TestuserDto
            {
                Age  = x.Age,
                Name = x.FirstName
            });

            a.Should().ThrowExactly <InvalidQueryPropertyException>();
        }
Exemple #4
0
        public void QueryPropertyWithProjectionWorksInIsolation_CustomAttributeName()
        {
            var result = UserQuery.BuildQuery(new TestUserSearch {
                CustomProp = 10
            }, x => new TestuserDto
            {
                Age  = x.Age,
                Name = x.FirstName
            });

            result.Should().HaveCount(1);
            result.All(x => x.Age == 10).Should().BeTrue();
            result.Any(x => x.Age != 10).Should().BeFalse();
            result.First().Name.Should().Be("John");
        }
Exemple #5
0
        public void QueryPropertyWithProjectionWorksInIsolation_OperatorAndNameProvided()
        {
            var result = UserQuery.BuildQuery(new TestUserSearch {
                CustomProp2 = "mar"
            }, x => new TestuserDto
            {
                Age  = x.Age,
                Name = x.FirstName
            });

            result.Should().HaveCount(1);
            result.All(x => x.Age == 20).Should().BeTrue();
            result.Any(x => x.Age != 20).Should().BeFalse();
            result.First().Name.Should().Be("Mark");
        }
Exemple #6
0
        public void WithPropertyWorksInIsolation()
        {
            var result = UserQuery.BuildQuery(new TestUserSearch {
                WithMarriedAt = true
            }).ToList();

            result.Should().HaveCount(1);
            result.First().FirstName.Should().Be("Tim");
            result.First().Username.Should().Be("tim1");

            result = UserQuery.BuildQuery(new TestUserSearch()).ToList();
            result.Should().HaveCount(3);
            result.First().FirstName.Should().Be("John");
            result.ElementAt(1).FirstName.Should().Be("Mark");
            result.ElementAt(2).FirstName.Should().Be("Tim");

            result = UserQuery.BuildQuery(new TestUserSearch {
                WithMarriedAt = false
            }).ToList();
            result.Should().HaveCount(2);
            result.First().FirstName.Should().Be("John");
            result.ElementAt(1).FirstName.Should().Be("Mark");
        }
Exemple #7
0
 public void ReturnsEntireQueryable_WhenBuildObjectIsNUll()
 {
     UserQuery.BuildQuery(null).Should().HaveCount(3);
 }