public void Complex2() { var termA = new FilterTerm(WorkitemToDo); termA.Greater(5); var termB = new FilterTerm(WorkitemToDo); termB.Less(10); var termC = new FilterTerm(WorkitemToDo); termC.GreaterOrEqual(20); var termD = new FilterTerm(WorkitemToDo); termD.LessOrEqual(30); var and1 = new AndFilterTerm(termA, termB); var and2 = new AndFilterTerm(termC, termD); var o = new OrFilterTerm(and1, and2); Assert.AreEqual("((Workitem.ToDo>'5';Workitem.ToDo<'10')|(Workitem.ToDo>='20';Workitem.ToDo<='30'))", o.Token); }
public void QueryStoryByChangeDate() { const int millisecondOffset = 5; var storyAsset = CreateDisposableStory(InitialStoryName, "Scope:0"); storyAsset = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery)[0]; var changeDate = (DateTime)storyAsset.GetAttribute(changeDateDef).Value; if (changeDate.Millisecond < millisecondOffset) { Assert.Ignore("Querying items by date with high precision does not make sense because seconds number will be changed by offset"); } var dateTerm = new FilterTerm(changeDateDef); dateTerm.Greater(changeDate.AddMilliseconds(-millisecondOffset)); var stories = GetStoryAssets(dateTerm); Assert.IsTrue(stories.Any(x => x.Oid.Momentless.Equals(storyAsset.Oid.Momentless))); dateTerm = new FilterTerm(changeDateDef); dateTerm.Less(changeDate.AddMilliseconds(-millisecondOffset)); stories = GetStoryAssets(dateTerm); Assert.IsFalse(stories.Any(x => x.Oid.Momentless.Equals(storyAsset.Oid.Momentless))); }
public void QueryStoryChangesWithInequalityFilter() { var storyAsset = CreateDisposableStory(InitialStoryName, "Scope:0"); storyAsset = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery)[0]; var moment1 = storyAsset.GetAttribute(momentDef).Value; storyAsset.SetAttributeValue(nameDef, ChangedStoryName); services.Save(storyAsset); storyAsset.SetAttributeValue(nameDef, FinalStoryName); services.Save(storyAsset); storyAsset = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery)[0]; var moment3 = storyAsset.GetAttribute(momentDef).Value; var filter = new FilterTerm(momentDef); filter.GreaterOrEqual(moment1); var assets = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery, filter, true); Assert.AreEqual(3, assets.Count); Assert.IsTrue(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(InitialStoryName))); Assert.IsTrue(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(ChangedStoryName))); Assert.IsTrue(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(FinalStoryName))); filter = new FilterTerm(momentDef); filter.Greater(moment1); assets = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery, filter, true); Assert.AreEqual(2, assets.Count); Assert.IsFalse(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(InitialStoryName))); Assert.IsTrue(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(ChangedStoryName))); Assert.IsTrue(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(FinalStoryName))); var lessFilter = new FilterTerm(momentDef); lessFilter.Less(moment3); var greaterFilter = new FilterTerm(momentDef); greaterFilter.Greater(moment1); var groupFilter = new AndFilterTerm(lessFilter, greaterFilter); assets = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery, groupFilter, true); Assert.AreEqual(1, assets.Count); Assert.IsFalse(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(InitialStoryName))); Assert.IsTrue(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(ChangedStoryName))); Assert.IsFalse(assets.Any(x => x.GetAttribute(nameDef).Value.Equals(FinalStoryName))); }
public void QueryStoryByChangeDate() { const int millisecondOffset = 5; var storyAsset = CreateDisposableStory(InitialStoryName, "Scope:0"); storyAsset = GetAssetsByOid(storyAsset.Oid.Momentless, attributesToQuery)[0]; var changeDate = (DateTime) storyAsset.GetAttribute(changeDateDef).Value; if(changeDate.Millisecond < millisecondOffset) { Assert.Ignore("Querying items by date with high precision does not make sense because seconds number will be changed by offset"); } var dateTerm = new FilterTerm(changeDateDef); dateTerm.Greater(changeDate.AddMilliseconds(-millisecondOffset)); var stories = GetStoryAssets(dateTerm); Assert.IsTrue(stories.Any(x => x.Oid.Momentless.Equals(storyAsset.Oid.Momentless))); dateTerm = new FilterTerm(changeDateDef); dateTerm.Less(changeDate.AddMilliseconds(-millisecondOffset)); stories = GetStoryAssets(dateTerm); Assert.IsFalse(stories.Any(x => x.Oid.Momentless.Equals(storyAsset.Oid.Momentless))); }