Exemple #1
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);
        }
Exemple #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);
        }
Exemple #3
0
        public void RegisteringTest()
        {
            Random            random = new Random();
            IRegisterableLake lake   = new SnowLake();

            lake.RegisterSingleton("id", () => random.Next());
            lake.RegisterSingleton("id", () => random.Next());
            lake.RegisterSingleton("id", () => random.Next());

            Assert.IsTrue(lake.GetComponents("id").Count() == 3);
            Assert.IsTrue(lake.GetComponents("id").ElementAt(0).Equals(lake.GetComponents("id").ElementAt(0)));
            Assert.IsTrue(lake.GetComponents("id").ElementAt(1).Equals(lake.GetComponents("id").ElementAt(1)));
            Assert.IsTrue(lake.GetComponents("id").ElementAt(2).Equals(lake.GetComponents("id").ElementAt(2)));
        }