Пример #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);
        }
Пример #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);
        }
Пример #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);
        }