Esempio n. 1
0
        public void ShouldReturnComponentOfType()
        {
            var state = new TestState();
            var fooComp = new FooComponent();
            var customFoo = new FooComponent { Test = "NewFoo" };
            state.AddComponent(fooComp);
            state.AddComponent(customFoo);

            Assert.IsInstanceOf<FooComponent>(state.GetComponent(typeof(FooComponent)));
        }
Esempio n. 2
0
        public void ShouldReturnComponentMatchingPredicate()
        {
            var state = new TestState();
            var fooComp = new FooComponent();
            var customFoo = new FooComponent { Test = "NewFoo" };
            state.AddComponent(fooComp);
            state.AddComponent(customFoo);

            // We have to do some null checking, as we have both Foo and Bar components
            // in the game state.

            Assert.AreEqual(state.GetComponent(c =>
            {
                var cf = c as FooComponent;
                return cf != null && cf.Test == "NewFoo";
            }), customFoo);
        }
Esempio n. 3
0
 var state = new TestState();
 var fooComp = new FooComponent();
 var customFoo = new FooComponent { Test = "NewFoo" };
 var barComp = new BarComponent();
 var customBar = new BarComponent { Test = "NewBar" };
 state.AddComponent(fooComp);
 state.AddComponent(customFoo);
 state.AddComponent(barComp);
 state.AddComponent(customBar);
 Assert.AreEqual(state.GetAllComponents().Count(), 4);
Esempio n. 4
0
            var state = new TestState();
            var fooComp = new FooComponent();
            var customFoo = new FooComponent { Test = "NewFoo" };
            state.AddComponent(fooComp);
            state.AddComponent(customFoo);

            // We have to do some null checking, as we have both Foo and Bar components
            // in the game state.

            Assert.AreEqual(state.GetComponent(c =>
            {
                var cf = c as FooComponent;
                return cf != null && cf.Test == "NewFoo";
            }), customFoo);
        }

        [Test]