Пример #1
0
        public void AddAttribute()
        {
            bool collectionChanged = false;

            Scene scene = new Scene("Test Scene");
            scene.Attributes.CollectionChanged += (sender, e) => collectionChanged = true;

            Attribute attribute = new Attribute("test");
            scene.AddAttribute(attribute);

            Assert.IsTrue(collectionChanged);
            Assert.AreEqual(1, scene.Attributes.Count(x => x.Name == "test"));
        }
Пример #2
0
        public void RemoveAttribute()
        {
            int eventsFired = 0;

            Scene scene = new Scene("Test Scene");
            scene.Attributes.CollectionChanged += (sender, e) => eventsFired++;

            Attribute attribute = new Attribute("test");
            scene.AddAttribute(attribute);
            scene.RemoveAttribute(attribute);

            Assert.AreEqual(2, eventsFired);
            Assert.AreEqual(0, scene.Attributes.Count(x => x.Name == "test"));
        }
Пример #3
0
        private Scene CreateScene(ParseTreeNode node)
        {
            Scene scene = new Scene(grammar.GetName(node));

            foreach (Tuple<string, object> attribute in GetProperties(node))
            {
                ParseTreeNode attributeNode = (ParseTreeNode)attribute.Item2;
                scene.AddAttribute(new Attribute(attribute.Item1) { Value = new Value(getStrVal(attributeNode)) });
            }

            foreach (ParseTreeNode managerNode in grammar.GetOfType(node, grammar.Manager))
            {
                Manager manager = CreateManager(managerNode);
                scene.AddManager(manager);
            }

            foreach (ParseTreeNode entityNode in grammar.GetOfType(node, grammar.Entity))
            {
                Entity entity = CreateEntity(entityNode, scene, false);
                scene.AddEntity(entity);
            }

            return scene;
        }
Пример #4
0
        public void Scene_RemoveAttribute()
        {
            var scene = new Scene("Test Scene");
            var attribute = new Attribute("test");
            scene.AddAttribute(attribute);
            scene.SelectedAttribute = attribute;

            CommandHelper.TestUndoableCommand(
                () => Assert.AreEqual(1, scene.Attributes.Count),
                () => scene.RemoveAttributeCommand.Execute(null),
                () => Assert.AreEqual(0, scene.Attributes.Count)
            );
        }
Пример #5
0
        public void SceneAttributeCannotInherit()
        {
            bool collectionChanged = false;

            Scene scene = new Scene("Test Scene");
            scene.Attributes.CollectionChanged += (o, e) => collectionChanged = true;

            Attribute attribute = new Attribute("test");
            scene.AddAttribute(attribute);

            Assert.IsTrue(collectionChanged);
            //Assert.IsFalse(attribute.CanInherit);
        }