public void TestWithoutDisplayFolders() { var handler = new TabularModelHandler(1470); var tree = new TabularUITree(handler); var model = handler.Model; tree.Options = LogicalTreeOptions.Default & ~LogicalTreeOptions.DisplayFolders; var t1 = model.AddTable("Table 1"); t1.AddDataColumn("Column 1"); t1.AddMeasure("Measure 1"); var cg1 = model.AddCalculationGroup("Calc Group 1"); cg1.Field.Name = "Field"; var ci1 = cg1.AddCalculationItem("Item 1"); var cg1Path = tree.GetPath(cg1); var ci1Path = tree.GetPath(ci1); Assert.AreEqual(5, ci1Path.FullPath.Length); Assert.IsTrue( ci1Path.FullPath.SequenceEqual( new object[] { model, model.Groups.Tables, cg1, cg1.Field, ci1 })); Assert.AreEqual(1, tree.GetChildren(cg1Path).Count()); cg1.Field.DisplayFolder = "Folder\\Subfolder"; Assert.AreEqual(5, tree.GetPath(ci1).FullPath.Length); }
public void PerformanceTest() { var handler = new TabularModelHandler("localhost", "AdventureWorks"); var uiTree = new TabularUITree(handler); handler.Model.Tables["Currency"].SetAnnotation("NotNull", "This is a test"); uiTree.FilterMode = FilterMode.Flat; var items = new List <ITabularNamedObject>(); uiTree.Filter = null; uiTree.Filter = ":GetAnnotation(\"NotNull\").Contains(\"test\")"; var sw = new Stopwatch(); sw.Start(); for (int i = 0; i < 1000; i++) { items.AddRange(uiTree.GetChildrenInternal(TreePath.Empty)); } sw.Stop(); // Run 1: 3935 // Run 2: 4042 Assert.IsTrue(sw.ElapsedMilliseconds < 1000); Assert.AreEqual(1000, items.Count); }
public void BasicLinqFilterTest() { var handler = new TabularModelHandler("localhost", "AdventureWorks"); var uiTree = new TabularUITree(handler); uiTree.FilterMode = FilterMode.Flat; uiTree.Filter = null; uiTree.Filter = ":ObjectType=\"Table\""; var items = uiTree.GetChildrenInternal(TreePath.Empty).ToList(); Assert.AreEqual(14, items.Count); }
public void BasicLinqFilterTest() { var handler = new TabularModelHandler(Constants.ServerName, "TomWrapperTest"); var uiTree = new TabularUITree(handler); uiTree.FilterMode = FilterMode.Flat; uiTree.Filter = null; uiTree.Filter = ":ObjectType=\"Table\""; var items = uiTree.GetChildrenInternal(TreePath.Empty).ToList(); Assert.AreEqual(15, items.Count); }
public void NullSafetyTest() { var handler = new TabularModelHandler("localhost", "AdventureWorks"); var uiTree = new TabularUITree(handler); handler.Model.Tables["Currency"].SetAnnotation("NotNull", "This is a test"); uiTree.FilterMode = FilterMode.Flat; uiTree.Filter = null; uiTree.Filter = ":GetAnnotation(\"NotNull\").Contains(\"test\")"; var items = uiTree.GetChildrenInternal(TreePath.Empty).ToList(); Assert.AreEqual(1, items.Count); }
public void TestWithDisplayFoldersShowHidden() { var handler = new TabularModelHandler(1470); var tree = new TabularUITree(handler); var model = handler.Model; tree.Options = LogicalTreeOptions.Default | LogicalTreeOptions.ShowHidden; var t1 = model.AddTable("Table 1"); t1.AddMeasure("Measure 1"); var cg1 = model.AddCalculationGroup("Calc Group 1"); var ci1 = cg1.AddCalculationItem("Item 1"); var cc1 = cg1.AddCalculatedColumn("Column 1"); var cg1Path = tree.GetPath(cg1); var ci1Path = tree.GetPath(ci1); var cc1Path = tree.GetPath(cc1); Assert.AreEqual(5, ci1Path.FullPath.Length); Assert.IsTrue( ci1Path.FullPath.SequenceEqual( new object[] { model, model.Groups.Tables, cg1, cg1.CalculationItems, ci1 })); Assert.AreEqual(4, tree.GetChildren(cg1Path).Count()); Assert.IsTrue(tree.GetChildren(cg1Path).OfType <object>().SequenceEqual(new object[] { cg1.CalculationItems, cg1.Columns["Name"], cg1.Columns["Ordinal"], cc1 })); Assert.IsTrue( cc1Path.FullPath.SequenceEqual( new object[] { model, model.Groups.Tables, cg1, cc1 })); cc1.DisplayFolder = "Folder\\Subfolder"; Assert.AreEqual(6, tree.GetPath(cc1).FullPath.Length); }