public static void ClassInitialize(TestContext testContext) { TestHelper.IndexThings(new Thing[] { new Thing() { Tags = TagQuery.MakeTags("shape:circle", "size:large") }, new Thing() { Tags = TagQuery.MakeTags("shape:circle", "size:medium") }, new Thing() { Tags = TagQuery.MakeTags("shape:circle", "size:small") }, new Thing() { Tags = TagQuery.MakeTags("shape:square", "size:large") }, new Thing() { Tags = TagQuery.MakeTags("shape:square", "size:medium") }, new Thing() { Tags = TagQuery.MakeTags("shape:square", "size:small") } }); }
public void Same_Tags_Same_Order() { var tagQuery1 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1", "tag2") }; var tagQuery2 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1", "tag2") }; Assert.AreEqual(tagQuery1, tagQuery2); }
public void Different_Tag_Collection_Of_Collections_Second_Empty() { var tagQuery1 = new TagQuery() { HasAnyAnd = new LookTag[][] { TagQuery.MakeTags("tag1", "tag2") } }; var tagQuery2 = new TagQuery() { HasAnyAnd = new LookTag[][] { } }; Assert.AreNotEqual(tagQuery1, tagQuery2); }
public void Different_Tags() { var tagQuery1 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1", "tag2") }; var tagQuery2 = new TagQuery() { HasAll = TagQuery.MakeTags("tag2", "tag3") }; Assert.AreNotEqual(tagQuery1, tagQuery2); }
public void Same_Tag_Collection_Of_Collections_Mixed_Up() { var tagQuery1 = new TagQuery() { HasAnyAnd = new LookTag[][] { TagQuery.MakeTags("tag2", "tag1"), TagQuery.MakeTags("tag3", "tag4") } }; var tagQuery2 = new TagQuery() { HasAnyAnd = new LookTag[][] { TagQuery.MakeTags("tag3", "tag4"), TagQuery.MakeTags("tag1", "tag2") } }; Assert.AreEqual(tagQuery1, tagQuery2); }
public void Same_Tags_Different_Quantity_Alternate() { var tagQuery1 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1", "tag1") }; var tagQuery2 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1") }; Assert.AreNotEqual(tagQuery1, tagQuery2); }
public void Different_Tags_Second_Empty() { var tagQuery1 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1") }; var tagQuery2 = new TagQuery() { HasAll = new LookTag[] { } }; Assert.AreNotEqual(tagQuery1, tagQuery2); }
public void All_Small_Or_Medium_Circles() { var lookQuery = new LookQuery(TestHelper.GetSearchingContext()); lookQuery.TagQuery = new TagQuery(); lookQuery.TagQuery.All = TagQuery.MakeTags("shape:circle"); lookQuery.TagQuery.Any = TagQuery.MakeTags("size:small", "size:medium"); var lookResult = LookService.RunQuery(lookQuery); Assert.IsTrue(lookResult.Success); Assert.AreEqual(2, lookResult.TotalItemCount); }
public void Null_Tags() { var tagQuery1 = new TagQuery() { HasAll = null }; var tagQuery2 = new TagQuery() { HasAll = TagQuery.MakeTags("tag1", "tag2") }; Assert.AreNotEqual(tagQuery1, tagQuery2); }
public static void ClassInitialize(TestContext testContext) { // create an index (doesn't need any data) but it needs to exist so we can get context TestHelper.IndexThings(new Thing[] { new Thing() { Tags = TagQuery.MakeTags("tag1") }, new Thing() { Tags = TagQuery.MakeTags("tag2") } }); }
public void Has_All() { var lookQuery = new LookQuery(TestHelper.GetSearchingContext()); lookQuery.TagQuery = new TagQuery() { HasAll = TagQuery.MakeTags("shape:circle") }; var lookResult = lookQuery.Search(); Assert.IsTrue(lookResult.Success); Assert.AreEqual(3, lookResult.TotalItemCount); }
public void Not_Any() { var lookQuery = new LookQuery(TestHelper.GetSearchingContext()); lookQuery.TagQuery = new TagQuery() { Has = new LookTag("shape"), // HACK: need to clear index on startup of this class NotAny = TagQuery.MakeTags("shape:circle", "shape:oblong") }; var lookResult = lookQuery.Search(); Assert.IsTrue(lookResult.Success); Assert.AreEqual(3, lookResult.TotalItemCount); }
public void String_Array() { var tags = TagQuery.MakeTags(new string[] { "colour:red", "colour:green", "colour:blue" }); Assert.AreEqual(3, tags.Length); Assert.AreEqual("colour", tags[0].Group); Assert.AreEqual("red", tags[0].Name); Assert.AreEqual("colour", tags[1].Group); Assert.AreEqual("green", tags[1].Name); Assert.AreEqual("colour", tags[2].Group); Assert.AreEqual("blue", tags[2].Name); }
public void String_Enumerable() { var tags = TagQuery.MakeTags(new string[] { "colour:red", "colour:green", "colour:blue" }.Select(x => x)); Assert.AreEqual(3, tags.Length); Assert.AreEqual("colour", tags[0].Group); Assert.AreEqual("red", tags[0].Name); Assert.AreEqual("colour", tags[1].Group); Assert.AreEqual("green", tags[1].Name); Assert.AreEqual("colour", tags[2].Group); Assert.AreEqual("blue", tags[2].Name); }
public void Tag_Any_Conflict() { var lookQuery = new LookQuery(TestHelper.GetSearchingContext()); lookQuery.TagQuery = new TagQuery() { HasAnyAnd = new LookTag[][] { TagQuery.MakeTags("tag1") }, NotAny = TagQuery.MakeTags("tag1") }; var lookResult = lookQuery.Search(); Assert.IsNotNull(lookResult); //Assert.IsFalse(lookResult.Success); Assert.IsTrue(lookResult.TotalItemCount == 0); }
public void Has_Any_And() { var lookQuery = new LookQuery(TestHelper.GetSearchingContext()); lookQuery.TagQuery = new TagQuery() { HasAnyAnd = new LookTag[][] { TagQuery.MakeTags("shape:circle", "shape:oblong"), // either of these TagQuery.MakeTags("size:small", "size:medium") // and either of these } }; var lookResult = lookQuery.Search(); Assert.IsTrue(lookResult.Success); Assert.AreEqual(4, lookResult.TotalItemCount); }
public void Has_All_Or() { var lookQuery = new LookQuery(TestHelper.GetSearchingContext()); lookQuery.TagQuery = new TagQuery() { HasAllOr = new LookTag[][] { TagQuery.MakeTags("shape:circle", "size:large"), TagQuery.MakeTags("shape:square", "size:large"), TagQuery.MakeTags("unknown") } }; var lookResult = lookQuery.Search(); Assert.IsTrue(lookResult.Success); Assert.AreEqual(2, lookResult.TotalItemCount); }