Ejemplo n.º 1
0
        public void DefaultComponentTest()
        {
            SnowLake lake = new SnowLake();

            lake.RegisterComponent("t", () => 10);
            lake.RegisterComponent("t", () => 1);
            lake.RegisterComponent("t", () => 2);
            Assert.IsTrue((lake.GetComponent("t") as int?) == 10);
        }
Ejemplo n.º 2
0
        public void ExtensionMethodTest()
        {
            IRegisterableLake lake = new SnowLake();

            lake.RegisterComponent("t", () => - 1);
            lake.RegisterComponent("t", () => 1);
            lake.RegisterComponent("t", () => 2);

            Assert.IsTrue(lake.GetComponents("t").Count() == 3);
            Assert.IsTrue((lake.GetComponent("t") as int?) == -1);
        }
Ejemplo n.º 3
0
        public void GetComponentsTest()
        {
            SnowLake lake = new SnowLake();

            lake.RegisterComponent("t", () => 0);
            lake.RegisterComponent("t", () => 1);
            lake.RegisterComponent("t", () => 2);
            Assert.IsTrue(lake.GetComponents("t").Count() == 3);

            var components = lake.GetComponents("t");

            Assert.IsTrue((components.ElementAt(0) as int?) == 0);
            Assert.IsTrue((components.ElementAt(1) as int?) == 1);
            Assert.IsTrue((components.ElementAt(2) as int?) == 2);
        }