public async Task ExecuteUserQuery() { var mockManager = new QueryMockManager(); var expectedPredicate = new SimplePredicate(nameof(User.NickName), ValueComparingOperator.StringContains, "Misko"); var mapperMock = mockManager.ConfigureMapperMock <User, UserDto, UserFilterDto>(); var queryMock = mockManager.ConfigureQueryMock <User>(); var productQueryObject = new UserQueryObject(mapperMock.Object, queryMock.Object); var unused = await productQueryObject.ExecuteQuery(new UserFilterDto { SubName = "Misko" }); Assert.AreEqual(mockManager.CapturedPredicate, expectedPredicate); }
public async Task ApplyWhereClause_EmptyFilter_ReturnsNull() { var mockManager = new QueryMockManager(); var mapperMock = mockManager.ConfigureMapperMock <User, UserDto, UserFilterDto>(); var queryMock = mockManager.ConfigureQueryMock <User>(); var userQueryObject = new UserQueryObject(mapperMock.Object, queryMock.Object); var filter = new UserFilterDto(); var temp = await userQueryObject.ExecuteQuery(filter); Assert.AreEqual(null, mockManager.CapturedPredicate); }
public async Task ApplyWhereClause_SimpleFilterByBornBefore_ReturnsCorrectPredicate() { DateTime filterBornBefore = new DateTime(2018, 12, 12); var mockManager = new QueryMockManager(); var expectedPredicate = new CompositePredicate( new List <IPredicate> { new SimplePredicate(nameof(User.Birthdate), ValueComparingOperator.LessThan, filterBornBefore) }, LogicalOperator.AND); var mapperMock = mockManager.ConfigureMapperMock <User, UserDto, UserFilterDto>(); var queryMock = mockManager.ConfigureQueryMock <User>(); var userQueryObject = new UserQueryObject(mapperMock.Object, queryMock.Object); var filter = new UserFilterDto { BornBefore = filterBornBefore }; var temp = await userQueryObject.ExecuteQuery(filter); Assert.AreEqual(expectedPredicate, mockManager.CapturedPredicate); }
public async Task ApplyWhereClause_SimpleFilterByEmail_ReturnsCorrectPredicate() { const string filteredEmail = "*****@*****.**"; var mockManager = new QueryMockManager(); var expectedPredicate = new CompositePredicate( new List <IPredicate> { new SimplePredicate(nameof(User.Email), ValueComparingOperator.Equal, filteredEmail) }, LogicalOperator.AND); var mapperMock = mockManager.ConfigureMapperMock <User, UserDto, UserFilterDto>(); var queryMock = mockManager.ConfigureQueryMock <User>(); var userQueryObject = new UserQueryObject(mapperMock.Object, queryMock.Object); var filter = new UserFilterDto { Email = filteredEmail }; var temp = await userQueryObject.ExecuteQuery(filter); Assert.AreEqual(expectedPredicate, mockManager.CapturedPredicate); }