Example #1
0
        public void EntityTransaction_MovePrototypeUp()
        {
            var prototype0 = new Entity() { Name = "prototype0" };
            var prototype1 = new Entity() { Name = "prototype0" };
            var entity = new Entity();
            var transaction = new EntityTransaction(new [] { prototype0, prototype1 }, entity);
            transaction.AddPrototype(prototype0);
            transaction.AddPrototype(prototype1);
            transaction.SelectedPrototype = prototype1;

            CommandHelper.TestCommand(
                () => transaction.MovePrototypeUpCommand.Execute(null),
                () =>
                {
                    Assert.AreEqual(0, transaction.SelectedPrototypes.IndexOf(prototype1));
                    Assert.AreEqual(1, transaction.SelectedPrototypes.IndexOf(prototype0));
                }
            );
        }
Example #2
0
        public void EntityTransaction_RemovePrototype()
        {
            var prototype = new Entity() { Name = "prototype" };
            var entity = new Entity();
            var transaction = new EntityTransaction(Enumerable.Repeat(prototype, 1), entity);
            transaction.AddPrototype(prototype);
            transaction.SelectedPrototype = prototype;

            CommandHelper.TestCommand(
                () => transaction.RemovePrototypeCommand.Execute(prototype),
                () =>
                {
                    Assert.AreEqual(1, transaction.AvailablePrototypes.Count);
                    Assert.AreEqual(0, transaction.SelectedPrototypes.Count);
                }
            );
        }
Example #3
0
        public void EntityTransaction_Commit()
        {
            var prototype = new Entity() { Name = "prototype" };
            var entity = new Entity();
            var transaction = new EntityTransaction(Enumerable.Repeat(prototype, 1), entity);
            transaction.Name = "testEntity";
            transaction.AddPrototype(prototype);
            transaction.AddComponent(transaction.AvailableComponents.First());

            CommandHelper.TestUndoableCommand(
                () =>
                {
                    Assert.IsNull(entity.Name);
                    Assert.AreEqual(0, entity.Prototypes.Count);
                    Assert.AreEqual(0, entity.Components.Count);
                },
                () => transaction.CommitCommand.Execute(null),
                () =>
                {
                    Assert.AreEqual("testEntity", entity.Name);
                    Assert.AreEqual(1, entity.Prototypes.Count);
                    Assert.AreEqual(1, entity.Components.Count);
                }
            );
        }