public void AllowAllDenySome2() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression <int>(); filterExpression.Include(x1 => true); filterExpression.Exclude(x2 => x2 > 2); filterExpression.Exclude(x3 => x3 < 2); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual(".Where(x2 => (Not((x2 > 2)) AndAlso Not((x2 < 2))))", mockQuery.GetWherePart(filteredQuery)); Assert.AreEqual("2", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void AllowSome2DenySome2() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression <int>(); filterExpression.Include(x1 => x1 >= 2); filterExpression.Include(x2 => x2 >= 4); filterExpression.Exclude(x3 => x3 >= 4); filterExpression.Exclude(x4 => x4 >= 5); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual(".Where(x1 => (((x1 >= 2) OrElse (x1 >= 4)) AndAlso (Not((x1 >= 4)) AndAlso Not((x1 >= 5)))))", mockQuery.GetWherePart(filteredQuery)); Assert.AreEqual("2, 3", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void DenySome() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression <int>(); filterExpression.Exclude(x => x >= 3); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual("New query: System.Int32[]", mockQuery.GetWherePart(filteredQuery), "Result should be a newly constructed empty array"); Assert.AreEqual("", TestUtility.Dump(filteredQuery)); Assert.AreEqual(0, mockQuery.CallCount, "Empty filter should be optimized to not use original query."); }
public void AllowSomeDenyNone() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression <int>(); filterExpression.Include(x1 => x1 >= 3); filterExpression.Exclude(x2 => false); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual(".Where(x1 => (x1 >= 3))", mockQuery.GetWherePart(filteredQuery)); Assert.AreEqual("3, 4", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void AllowAllDenyNone() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression <int>(); filterExpression.Include(x1 => true); filterExpression.Exclude(x2 => false); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual("", mockQuery.GetWherePart(filteredQuery), "Optimized - No where part"); Assert.AreEqual("1, 2, 3, 4", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void AllowSome2DenySome2() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression<int>(); filterExpression.Include(x1 => x1 >= 2); filterExpression.Include(x2 => x2 >= 4); filterExpression.Exclude(x3 => x3 >= 4); filterExpression.Exclude(x4 => x4 >= 5); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual(".Where(x1 => (((x1 >= 2) OrElse (x1 >= 4)) AndAlso (Not((x1 >= 4)) AndAlso Not((x1 >= 5)))))", mockQuery.GetWherePart(filteredQuery)); Assert.AreEqual("2, 3", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void AllowAllDenySome2() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression<int>(); filterExpression.Include(x1 => true); filterExpression.Exclude(x2 => x2 > 2); filterExpression.Exclude(x3 => x3 < 2); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual(".Where(x2 => (Not((x2 > 2)) AndAlso Not((x2 < 2))))", mockQuery.GetWherePart(filteredQuery)); Assert.AreEqual("2", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void DenySome() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression<int>(); filterExpression.Exclude(x => x >= 3); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual("New query: System.Int32[]", mockQuery.GetWherePart(filteredQuery), "Result should be a newly constructed empty array"); Assert.AreEqual("", TestUtility.Dump(filteredQuery)); Assert.AreEqual(0, mockQuery.CallCount, "Empty filter should be optimized to not use original query."); }
public void AllowSomeDenyNone() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression<int>(); filterExpression.Include(x1 => x1 >= 3); filterExpression.Exclude(x2 => false); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual(".Where(x1 => (x1 >= 3))", mockQuery.GetWherePart(filteredQuery)); Assert.AreEqual("3, 4", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }
public void AllowAllDenyNone() { var mockQuery = new MockQuery(); var query = mockQuery.Query(); var filterExpression = new FilterExpression<int>(); filterExpression.Include(x1 => true); filterExpression.Exclude(x2 => false); var filteredQuery = GetOpt(filterExpression.GetFilter(), query); Assert.AreEqual("", mockQuery.GetWherePart(filteredQuery), "Optimized - No where part"); Assert.AreEqual("1, 2, 3, 4", TestUtility.Dump(filteredQuery)); Assert.AreEqual(1, mockQuery.CallCount); }