コード例 #1
0
        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);
        }
コード例 #2
0
        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 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 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)));
		}