public void EmptyResultWhenSingleMatchingItemIsNegated() { var context = new Dictionary<string, string> { {"A", "2"}, }; var items = new[] { new Item(1,new TextMatchCondition("A","1")), new Item(2,new TextMatchCondition("A","2",true)), new Item(3,new TextMatchCondition("A","1")), }; var evaluationResult = new FilterConditionsEvaluator().Evaluate(context, items); var result = new SelectAllRelevantFilterPolicy().Filter(evaluationResult).Select(x => x.Item).OfType<Item>(); Assert.IsFalse(result.Any()); }
public void SelectTwoItemsWithReferences() { var context = new Dictionary<string, string> { {"A", "2"}, }; var items = new[] { new Item(1,new TextMatchCondition("A","1")), new Item(2,new TextMatchCondition("A","2")), new Item(3,new TextMatchCondition("A","2")), new Item(4,new TextMatchCondition("A","1")), }; var evaluationResult = new FilterConditionsEvaluator().Evaluate(context, items); var result = new SelectAllRelevantFilterPolicy().Filter(evaluationResult).Select(x => x.Item).OfType<Item>(); Assert.IsTrue(result.Any(x => x.Id == 2)); Assert.IsTrue(result.Any(x => x.Id == 3)); Assert.IsTrue(result.Count() == 2); }
public void SelectTwoItemsThatHasAMatchingReferenceToASubjectAndOneOfThemHasAlsoAReferenceToTheSameSubjectButWithDifferentValue() { var context = new Dictionary<string, string> { {"A", "2"}, {"B", "2"}, {"C", "2"}, {"D", "2"}, {"E", "2"}, }; var items = new[] { new Item(1,new TextMatchCondition("A","2")), new Item(2,new TextMatchCondition("B","2"),new TextMatchCondition("A","1")), new Item(3,new TextMatchCondition("A","2"),new TextMatchCondition("A","1")), }; var evaluationResult = new FilterConditionsEvaluator().Evaluate(context, items); var result = new SelectAllRelevantFilterPolicy().Filter(evaluationResult).Select(x => x.Item).OfType<Item>(); Assert.IsTrue(result.Count() == 2); Assert.IsTrue(result.Any(x => x.Id == 1)); Assert.IsTrue(result.Any(x => x.Id == 3)); }