Example #1
0
        public void FindsAllMatches()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var glob = new GlobParser().Parse("**/hd??");

            var matches = new GlobMatchEnumerator(glob).EnumerateMatches(hierarchy);

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda1",
                "hdb1",
                "hdb2",
                "hdmi"
            }));
        }
        public void Should_handle_GetParent_operation_over_larger_hierarchy()
        {
            // build a sample hierarchy
            var hierarchyEntry = new HierarchyEntry
            {
                Name       = "Test Hierarchy",
                SchemaName = "dbo",
                TableName  = "test"
            };

            // initialize the provider
            var dataProvider = new MssqlDataProvider();
            var provider     = new MssqlHierarchyDataProvider(dataProvider);

            // generate the complex hierarchy
            TestHierarchy.BuildTestHierarchy(hierarchyEntry, provider);

            var rootNode          = provider.GetRootNode(hierarchyEntry);
            var primaryChildren   = provider.GetChildren(hierarchyEntry, rootNode);
            var primaryChild1     = primaryChildren.First();
            var secondaryChildren = provider.GetChildren(hierarchyEntry, primaryChild1);
            var leafChild         = secondaryChildren.First();

            var parent = provider.GetParent(hierarchyEntry, leafChild);

            Assert.That(parent.LeftId, Is.LessThan(leafChild.LeftId));
            Assert.That(parent.RightId, Is.GreaterThan(leafChild.RightId));

            // clean up
            dataProvider.DropTable(hierarchyEntry.SchemaName, hierarchyEntry.TableName);
        }
Example #3
0
        public void EarlierRulesTakePrecedence_ExcludeBeforeInclude()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var enumerator = new MultiGlobMatchEnumerator().Include(parser.Parse("**"));
            var filter     = new MultiGlobMatchFilter(hierarchy.CaseSensitive)
                             .Exclude(parser.Parse("dev/**"))
                             .Include(parser.Parse("**/hd[am]?"));

            var matches = enumerator.EnumerateMatches(hierarchy)
                          .Where(filter.Filter)
                          .ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hdmi",
            }));
        }
Example #4
0
        public void TRS_TestHierarchyAddExtraChildrenChangeArchetype()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            testHierarchy.Create();
            testHierarchy.Update();

            // Add a lot more than parent count children on same frame
            var childCount = 5;

            for (int i = 0; i < testHierarchy.Entities.Length; i++)
            {
                var parent = testHierarchy.Entities[i];
                for (int j = 0; j < childCount; j++)
                {
                    var child = m_Manager.CreateEntity(typeof(LocalToWorld));
                    m_Manager.AddComponentData(child, new Parent {
                        Value = parent
                    });
                    m_Manager.AddComponentData(child, new LocalToParent {
                        Value = float4x4.identity
                    });
                }
            }

            testHierarchy.Update();
            testHierarchy.Update();

            testHierarchy.Dispose();
        }
Example #5
0
        public void FindsAllUniqueMatchesOfIncludesNotMatchedByExcludes()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("home/*/**"))
                          .Include(parser.Parse("**/h*"))
                          .EnumerateMatches(hierarchy);

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda",
                "hda1",
                "hdb",
                "hdb1",
                "hdb2",
                "home"
            }));
        }
Example #6
0
        public void MatcherWithOnlyRecursiveExclusionRulesMatchingWithinASubtree_DoesNotMatchWithinThatSubtree()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("d*/**"))
                          .Include(parser.Parse("d*"))
                          .EnumerateMatches(hierarchy).ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "dev",
            }));
        }
Example #7
0
        public void MatcherWithOnlyExclusionRulesMatchingInitially_MatchesNothing()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser = new GlobParser();

            var matches = new MultiGlobMatchEnumerator()
                          .Exclude(parser.Parse("dev/**"))
                          .Exclude(parser.Parse("**/hd[am]?"))
                          .Include(parser.Parse("nothing/**"))
                          .EnumerateMatches(hierarchy).ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(), Is.Empty);
        }
Example #8
0
        public void TRS_TestHierarchyFirstUpdateWitCompositeScaleParentScaleInverse()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            testHierarchy.CreateWithCompositeScaleParentScaleInverse();
            testHierarchy.Update();

            testHierarchy.TestExpectedLocalToParent();

            testHierarchy.Dispose();
        }
Example #9
0
        public void TRS_TestHierarchyFirstUpdate()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            testHierarchy.Create();
            testHierarchy.Update();

            testHierarchy.TestExpectedLocalToParent();
            testHierarchy.TestExpectedLocalToWorld();

            testHierarchy.Dispose();
        }
        public void TestIHierarchicalEnumerableDataSource()
        {
            List <TestNode> list = new List <TestNode> ();

            list.Add(new TestNode("test", null, null));
            TestHierarchy hierarchy          = new TestHierarchy(list);
            MyHierarchicalDataBoundControl c = new MyHierarchicalDataBoundControl();

            c.DataSource = hierarchy;
            c.DataBind();
            HierarchicalDataSourceView view = c.GetData("");

            Assert.IsNotNull(view);
        }
Example #11
0
        public void TRS_TestHierarchyAfterParentDeleted()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            testHierarchy.Create();
            testHierarchy.Update();

            testHierarchy.DeleteSomeParents();
            testHierarchy.Update();

            testHierarchy.TestExpectedLocalToParent();
            testHierarchy.TestExpectedLocalToWorld();

            testHierarchy.Dispose();
        }
Example #12
0
        public void TRS_TestHierarchyAddExtraChildrenChangeParentAgain()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            testHierarchy.Create();
            testHierarchy.Update();

            // Add a lot more than parent count children on same frame
            var childCount = 5;

            var children = new NativeArray <Entity>(testHierarchy.Entities.Length * childCount, Allocator.TempJob);

            for (int i = 0; i < testHierarchy.Entities.Length; i++)
            {
                var parent = testHierarchy.Entities[i];
                for (int j = 0; j < childCount; j++)
                {
                    var child = m_Manager.CreateEntity(typeof(LocalToWorld), typeof(Parent), typeof(LocalToParent));
                    m_Manager.SetComponentData(child, new Parent {
                        Value = parent
                    });
                    m_Manager.SetComponentData(child, new LocalToParent {
                        Value = float4x4.identity
                    });
                    children[(i * childCount) + j] = child;
                }
            }

            testHierarchy.Update();

            // Change parents
            for (int i = 0; i < testHierarchy.Entities.Length; i++)
            {
                var parent = testHierarchy.Entities[i];
                for (int j = 0; j < childCount; j++)
                {
                    var child = children[(i * childCount) + j];
                    m_Manager.SetComponentData(child, new Parent {
                        Value = parent
                    });
                }
            }

            testHierarchy.Update();
            children.Dispose();
            testHierarchy.Dispose();
        }
Example #13
0
        public void ContainerExclusionDoesNotApplyRecursively()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser   = new GlobParser();
            var includes = new []
            {
                parser.Parse("**/h*")
            };
            var excludes = new []
            {
                parser.Parse("home")
            };

            var enumerator = new MultiGlobMatchEnumerator().Include(parser.Parse("**"));
            var filter     = new MultiGlobMatchFilter(hierarchy.CaseSensitive)
                             .Exclude(excludes)
                             .Include(includes);

            var matches = enumerator.EnumerateMatches(hierarchy)
                          .Where(filter.Filter)
                          .ToArray();

            Assert.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda",
                "hda1",
                "hdb",
                "hdb1",
                "hdb2",
                "hdmi"
            }));
        }
        public void TRS_TestHierarchyUpdatesNestedParentsChildWithWriteGroups()
        {
            // P
            // -- C1 <- This has an archetype with writegroup for LocalToWorld
            // -- -- C2 <- Normal child, this should be updated by LocalToParentSystem if I modify C1's LocalToWorld in a custom system

            var testHierarchy = new TestHierarchy(World, m_Manager);
            var c2Entity      = testHierarchy.CreateWithWriteGroupChildren();

            testHierarchy.Update();
            World.GetOrCreateSystem <TestTransformWriteGroupSystem>().Update();
            testHierarchy.Update();

            var localToWorld         = m_Manager.GetComponentData <LocalToWorld>(c2Entity);
            var expectedLocalToWorld = new float4x4(float3x3.identity, new float3(42));

            TestHierarchy.AssertCloseEnough(expectedLocalToWorld, localToWorld.Value);
        }
Example #15
0
        public void LocalToParentConsidersWriteGroups()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            var parent     = m_Manager.CreateEntity(typeof(LocalToWorld), typeof(Translation));
            var child      = m_Manager.CreateEntity(typeof(LocalToWorld), typeof(Parent), typeof(LocalToParent));
            var childChild = m_Manager.CreateEntity(typeof(LocalToWorld), typeof(Parent), typeof(LocalToParent));

            m_Manager.SetComponentData(parent, new LocalToWorld {
                Value = float4x4.identity
            });
            m_Manager.SetComponentData(child, new Parent {
                Value = parent
            });
            m_Manager.SetComponentData(child, new LocalToParent {
                Value = float4x4.identity
            });
            m_Manager.SetComponentData(childChild, new Parent {
                Value = child
            });
            m_Manager.SetComponentData(childChild, new LocalToParent {
                Value = float4x4.identity
            });

            m_Manager.SetComponentData(parent, new Translation {
                Value = new float3(2, 2, 2)
            });
            testHierarchy.Update();
            Assert.AreEqual(new float3(2, 2, 2), m_Manager.GetComponentData <LocalToWorld>(child).Position);
            Assert.AreEqual(new float3(2, 2, 2), m_Manager.GetComponentData <LocalToWorld>(childChild).Position);

            m_Manager.AddComponentData(child, new LocalToWorldWriteGroupComponent());
            m_Manager.SetComponentData(parent, new Translation {
                Value = new float3(3, 3, 3)
            });

            m_Manager.SetComponentData(child,
                                       new LocalToWorld {
                Value = math.mul(float4x4.Translate(new float3(4, 4, 4)), float4x4.identity)
            });
            testHierarchy.Update();
            Assert.AreEqual(new float3(4, 4, 4), m_Manager.GetComponentData <LocalToWorld>(child).Position);
            Assert.AreEqual(new float3(4, 4, 4), m_Manager.GetComponentData <LocalToWorld>(childChild).Position);
        }
        public void Should_handle_GetDescendants_operation_over_larger_hierarchy()
        {
            // build a sample hierarchy
            var hierarchyEntry = new HierarchyEntry
            {
                Name       = "Test Hierarchy",
                SchemaName = "dbo",
                TableName  = "test"
            };

            // initialize the provider
            var dataProvider = new MssqlDataProvider();
            var provider     = new MssqlHierarchyDataProvider(dataProvider);

            // generate the complex hierarchy
            TestHierarchy.BuildTestHierarchy(hierarchyEntry, provider);

            var rootNode    = provider.GetRootNode(hierarchyEntry);
            var descendants = provider.GetDescendants(hierarchyEntry, rootNode, true, true);

            Assert.That(descendants.Count, Is.EqualTo(7));
            Assert.That(descendants[0].LeftId, Is.EqualTo(1));
            Assert.That(descendants[0].RightId, Is.EqualTo(14));
            Assert.That(descendants[1].LeftId, Is.EqualTo(2));
            Assert.That(descendants[1].RightId, Is.EqualTo(7));
            Assert.That(descendants[2].LeftId, Is.EqualTo(3));
            Assert.That(descendants[2].RightId, Is.EqualTo(4));
            Assert.That(descendants[3].LeftId, Is.EqualTo(5));
            Assert.That(descendants[3].RightId, Is.EqualTo(6));
            Assert.That(descendants[4].LeftId, Is.EqualTo(8));
            Assert.That(descendants[4].RightId, Is.EqualTo(13));
            Assert.That(descendants[5].LeftId, Is.EqualTo(9));
            Assert.That(descendants[5].RightId, Is.EqualTo(10));
            Assert.That(descendants[6].LeftId, Is.EqualTo(11));
            Assert.That(descendants[6].RightId, Is.EqualTo(12));

            Assert.That(rootNode.LeftId, Is.EqualTo(1));
            Assert.That(rootNode.RightId, Is.EqualTo(14));

            // clean up
            dataProvider.DropTable(hierarchyEntry.SchemaName, hierarchyEntry.TableName);
        }
Example #17
0
        public void TRS_TestHierarchyDestroyAll()
        {
            var testHierarchy = new TestHierarchy(World, m_Manager);

            testHierarchy.Create();
            testHierarchy.Update();

            // Make sure can handle destroying all parents and children on same frame
            testHierarchy.DestroyAll();
            testHierarchy.Update();

            // Make sure remaining cleanup handled cleanly.
            testHierarchy.Update();

            var entities = m_Manager.GetAllEntities();

            Assert.IsTrue(entities.Length == 0);

            testHierarchy.Dispose();
        }
Example #18
0
        public void Setup()
        {
            animation = new Components.Animation();
            h         = new TestHierarchy();

            leftRight = new AnimationClip()
            {
                length = 1
            };
            simple = new AnimationCurve()
            {
                PreLoop = CurveLoopType.Constant, PostLoop = CurveLoopType.Constant
            };
            empty = new AnimationCurve()
            {
                PreLoop = CurveLoopType.Constant, PostLoop = CurveLoopType.Constant
            };
            simple.Keys.Add(new CurveKey(0, 0, 10, 10, CurveContinuity.Smooth));
            simple.Keys.Add(new CurveKey(0.5f, 5, 0, 0, CurveContinuity.Smooth));
            simple.Keys.Add(new CurveKey(1, 0, 0, 0, CurveContinuity.Smooth));
        }
Example #19
0
        public void YieldsDetailsForEveryMatchingIncludeGlob()
        {
            var hierarchy = new TestHierarchy(
                new SimpleMatchable("root",
                                    new SimpleMatchable("dev",
                                                        new SimpleMatchable("hda"),
                                                        new SimpleMatchable("hda1"),
                                                        new SimpleMatchable("hdb"),
                                                        new SimpleMatchable("hdb1"),
                                                        new SimpleMatchable("hdb2")),
                                    new SimpleMatchable("home",
                                                        new SimpleMatchable("me",
                                                                            new SimpleMatchable("hdmi")),
                                                        new SimpleMatchable("you")),
                                    new SimpleMatchable("var")));

            var parser   = new GlobParser();
            var includes = new []
            {
                parser.Parse("**/hd[am]?"),
                parser.Parse("home/**")
            };

            var matches = new MultiGlobMatchEnumerator()
                          .Include(includes)
                          .EnumerateMatches(hierarchy).ToArray();

            Assume.That(matches.Select(m => m.Item.Name).ToArray(),
                        Is.EquivalentTo(new []
            {
                "hda1",
                "me",
                "hdmi",
                "you"
            }));

            var hdmiMatch = matches.Single(m => m.Item.Name == "hdmi");

            Assert.That(hdmiMatch.Details.Select(s => s.Glob).ToArray(), Is.EquivalentTo(includes));
        }
        public void Should_handle_GetAncestors_operation_over_larger_hierarchy()
        {
            // build a sample hierarchy
            var hierarchyEntry = new HierarchyEntry
            {
                Name       = "Test Hierarchy",
                SchemaName = "dbo",
                TableName  = "test"
            };

            // initialize the provider
            var dataProvider = new MssqlDataProvider();
            var provider     = new MssqlHierarchyDataProvider(dataProvider);

            // generate the complex hierarchy
            TestHierarchy.BuildTestHierarchy(hierarchyEntry, provider);

            var rootNode          = provider.GetRootNode(hierarchyEntry);
            var primaryChildren   = provider.GetChildren(hierarchyEntry, rootNode);
            var primaryChild1     = primaryChildren.First();
            var secondaryChildren = provider.GetChildren(hierarchyEntry, primaryChild1);
            var leafChild         = secondaryChildren.First();

            var ancestors = provider.GetAncestors(hierarchyEntry, leafChild, true, true);

            Assert.That(ancestors.Count, Is.EqualTo(3));
            Assert.That(ancestors[0].LeftId, Is.EqualTo(1));
            Assert.That(ancestors[0].RightId, Is.EqualTo(14));
            Assert.That(ancestors[1].LeftId, Is.EqualTo(2));
            Assert.That(ancestors[1].RightId, Is.EqualTo(7));
            Assert.That(ancestors[2].LeftId, Is.EqualTo(leafChild.LeftId));
            Assert.That(ancestors[2].RightId, Is.EqualTo(leafChild.RightId));

            // clean up
            dataProvider.DropTable(hierarchyEntry.SchemaName, hierarchyEntry.TableName);
        }
		public void TestIHierarchicalEnumerableDataSource ()
		{
			List<TestNode> list = new List<TestNode> ();
			list.Add (new TestNode ("test", null, null));
			TestHierarchy hierarchy = new TestHierarchy (list);
			MyHierarchicalDataBoundControl c = new MyHierarchicalDataBoundControl ();
			c.DataSource = hierarchy;
			c.DataBind ();
			HierarchicalDataSourceView view = c.GetData ("");
			Assert.IsNotNull (view);
		}
Example #22
0
 public void Setup()
 {
     h = new TestHierarchy();
 }
        public void Setup()
        {
            animation = new Components.Animation();
            h = new TestHierarchy();

            leftRight = new AnimationClip() { length = 1 };
            simple = new AnimationCurve() { PreLoop = CurveLoopType.Constant, PostLoop = CurveLoopType.Constant };
            empty = new AnimationCurve() { PreLoop = CurveLoopType.Constant, PostLoop = CurveLoopType.Constant };
            simple.Keys.Add(new CurveKey(0, 0, 10, 10, CurveContinuity.Smooth));
            simple.Keys.Add(new CurveKey(0.5f, 5, 0, 0, CurveContinuity.Smooth));
            simple.Keys.Add(new CurveKey(1, 0, 0, 0, CurveContinuity.Smooth));
        }
Example #24
0
        public void InADeepHiearachyRootWillBeTheTopmostElement()
        {
            TestHierarchy h = new TestHierarchy();

            Assert.That(h.childOfChildTrans.root, Is.SameAs(h.rootTrans));
        }
Example #25
0
 public void CreateHierarchy( )
 {
     h = new TestHierarchy();
 }
 public void InADeepHiearachyRootWillBeTheTopmostElement()
 {
     TestHierarchy h = new TestHierarchy();
     Assert.That(h.childOfChildTrans.root, Is.SameAs(h.rootTrans));
 }