public void QueryPropertiesWorksInIsolation() { var result = UserQuery.BuildQuery(new TestUserSearch { Keyword = "m" }); result.Should().HaveCount(2); result.All(x => x.Age == 20).Should().BeTrue(); }
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(); }
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>(); }
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"); }
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"); }
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"); }
public void ReturnsEntireQueryable_WhenBuildObjectIsNUll() { UserQuery.BuildQuery(null).Should().HaveCount(3); }