Exemplo n.º 1
0
        public void SelectDefaultWhenNoItemWithHighestScoreFound()
        {
            var result = new QueryEngineBuilder().Get(new[] {
                QueriableItem.Create(new DefaultValueProvider(1),new IFilterCondition[]{new TextMatchCondition("env",null)}),
                QueriableItem.Create(new DefaultValueProvider(2),new IFilterCondition[]{}),
            }, false).Query(new Dictionary<string, string>());

            Assert.AreEqual(1, result.Length);
            Assert.AreEqual(2, result.Single().Get());
        }
Exemplo n.º 2
0
        public void SelectSingleItemWhenOneItemHasOneSpecificReferenceAndTheOtherHasTwoSpecificReferences()
        {
            var context = new Dictionary<string, string>
                              {
                                  {"A", "2"},
                                  {"B", "2"},
                              };

            var result = new QueryEngineBuilder().Get(new[] {
                QueriableItem.Create(new DefaultValueProvider(1),new IFilterCondition[]{new TextMatchCondition("A","2",false)}),
                QueriableItem.Create(new DefaultValueProvider(2),new IFilterCondition[]{new TextMatchCondition("B","2",false),new TextMatchCondition("A","2",false)}),
            }, false)
            .Query(context).Select(x => x.Get()).Cast<int>();

            Assert.IsTrue(result.Count() == 1);
            Assert.IsTrue(result.Single() == 2);
        }
Exemplo n.º 3
0
        public void EmptyResultWhenSingleNoneMatchingItemIsNegated()
        {
            var context = new Dictionary<string, string>
                              {
                                  {"A", "2"},
                                  {"B", "2"},
                              };

            var result = new QueryEngineBuilder().Get(new[] {
                QueriableItem.Create(new DefaultValueProvider(1),new IFilterCondition[]{new TextMatchCondition("B","1",false)}),
                QueriableItem.Create(new DefaultValueProvider(2),new IFilterCondition[]{new TextMatchCondition("A","1",true)}),
                QueriableItem.Create(new DefaultValueProvider(3),new IFilterCondition[]{new TextMatchCondition("B","1",false)}),
            }, true)
            .Query(context).Select(x => x.Get()).Cast<int>();

            Assert.IsTrue(result.Count()== 1);
            Assert.IsTrue(result.Single() == 2);
        }
Exemplo n.º 4
0
        public void SelectSingleWhenValueHasTwoReferencesToSameSubjectAndOnlyOneMatch2()
        {
            var context = new Dictionary<string, string>
                {
                    {"B", "3"},
                };

            var result = new QueryEngineBuilder().Get(new[] {
                QueriableItem.Create(new DefaultValueProvider(1),new IFilterCondition[]{new TextMatchCondition("A","3",false)}),
                QueriableItem.Create(new DefaultValueProvider(2),new IFilterCondition[]{new TextMatchCondition("B","3",false),new TextMatchCondition("B","4",false)}),
            }, false)
            .Query(context).Select(x => x.Get()).Cast<int>();

            Assert.AreEqual(1, result.Count());
            Assert.IsTrue(result.Single() == 2);
        }
Exemplo n.º 5
0
        public void with_two_items_while_one_is_with_one_true_condition_and_the_other_with_one_true_and_the_other_negated_true()
        {
            var context = new Dictionary<string, string>
                {
                    {"subject1", "a"},
                    {"subject2", "c"}
                };
            var result = new QueryEngineBuilder().Get(new[] {
                QueriableItem.Create(new DefaultValueProvider(1),new IFilterCondition[]{new TextMatchCondition("subject1","a")}),
                QueriableItem.Create(new DefaultValueProvider(2),new IFilterCondition[]{new TextMatchCondition("subject1","a"), new TextMatchCondition("subject2","b",true)}),
            }, false)
            .Query(context);

            Assert.AreEqual(1, result.Length);
            Assert.AreEqual(2, result.Single().Get());
        }