Example #1
0
        public void GetAndRemoveTest()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(9, 0))
            {
                Assert.Ignore("Ignoring GameplayKit tests: Requires iOS9+");
            }

            var entity = GKEntity.GetEntity();

            entity.AddComponent(new NumberComponent(10));
            entity.AddComponent(new NameComponent("Ten"));
            Assert.IsTrue(entity.Components.Length == 2, "entity.Components length must be 2");

            // Test component retrieval by type
            var component = entity.GetComponent(typeof(NumberComponent)) as NumberComponent;

            Assert.NotNull(component, "Component must not be null");
            Assert.IsTrue(component.Id == 10, "Component Id must be 10");

            // Test component removal by type
            Assert.NotNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must not be null");
            entity.RemoveComponent(typeof(NameComponent));
            Assert.IsTrue(entity.Components.Length == 1, "entity.Components length must be 1");
            Assert.IsNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must be null");
        }
        public void BadRemoval()
        {
            TestRuntime.AssertXcodeVersion(7, 0);

            var entity = GKEntity.GetEntity();

            Assert.Throws <ArgumentNullException> (() => entity.RemoveComponent(null));
        }
Example #3
0
        public void BadRemoval()
        {
            TestRuntime.AssertXcodeVersion(7, 0);

            var entity = GKEntity.GetEntity();

            entity.RemoveComponent(null);
        }
Example #4
0
        public void BadRemoval()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(9, 0))
            {
                Assert.Ignore("Ignoring GameplayKit tests: Requires iOS9+");
            }

            var entity = GKEntity.GetEntity();

            entity.RemoveComponent(null);
        }
        public void GetAndRemoveTest()
        {
            TestRuntime.AssertXcodeVersion(7, 0);

            var entity = GKEntity.GetEntity();

            entity.AddComponent(new NumberComponent(10));
            entity.AddComponent(new NameComponent("Ten"));
            Assert.IsTrue(entity.Components.Length == 2, "entity.Components length must be 2");

            // Test component retrieval by type
            var component = entity.GetComponent(typeof(NumberComponent)) as NumberComponent;

            Assert.NotNull(component, "Component must not be null");
            Assert.IsTrue(component.Id == 10, "Component Id must be 10");

            // Test component removal by type
            Assert.NotNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must not be null");
            entity.RemoveComponent(typeof(NameComponent));
            Assert.IsTrue(entity.Components.Length == 1, "entity.Components length must be 1");
            Assert.IsNull(entity.GetComponent(typeof(NameComponent)), "Component typeof NameComponent must be null");
        }