Esempio n. 1
0
        public void TypeValue_Test2()
        {
            var type           = typeof(IValueService);
            var container      = new IocContainer();
            var childContainer = new IocContainer(container);

            container.AddValue(type, "A", 15);
            Assert.Equal(15, childContainer.GetValue(type, "A"));

            int index = 0;

            container.AddValue(type, "B", lmp => ++ index);
            Assert.Equal(1, childContainer.GetValue(type, "B"));
            Assert.Equal(2, childContainer.GetValue(type, "B"));
            index = 0;

            container.AddValue(type, "C", lmp => ++ index, true);

            Assert.Equal(1, childContainer.GetValue(type, "C"));
            Assert.Equal(1, childContainer.GetValue(type, "C"));

            Assert.True(childContainer.ContainsValue(type, "A", true));
            container.RemoveValue(type, "A", true);
            Assert.False(childContainer.ContainsValue(type, "A", true));

            index = 0;
            container.AddValue(type, "D", lmp => ++ index);
            Assert.Equal(1, childContainer.GetValue(type, "D"));
            Assert.Equal(2, container.GetValue(type, "D"));
        }
Esempio n. 2
0
        public void Value_Test1()
        {
            var container = new IocContainer();

            container.AddValue("A", 15);
            Assert.Equal(15, container.GetValue("A"));

            int index = 0;

            container.AddValue("B", lmp => ++ index);
            Assert.Equal(1, container.GetValue("B"));
            Assert.Equal(2, container.GetValue("B"));
            index = 0;

            container.AddValue("C", lmp => ++ index, true);

            Assert.Equal(1, container.GetValue("C"));
            Assert.Equal(1, container.GetValue("C"));

            Assert.True(container.ContainsValue("A"));
            container.RemoveValue("A");
            Assert.False(container.ContainsValue("A"));
        }
Esempio n. 3
0
        public void TypeValue_Test2()
        {
            var type = typeof(IValueService);
            var container = new IocContainer();
            var childContainer = new IocContainer(container);
            container.AddValue(type, "A", 15);
            Assert.Equal(15, childContainer.GetValue(type, "A"));

            int index = 0;
            container.AddValue(type, "B", lmp => ++index);
            Assert.Equal(1, childContainer.GetValue(type, "B"));
            Assert.Equal(2, childContainer.GetValue(type, "B"));
            index = 0;

            container.AddValue(type, "C", lmp => ++index, true);

            Assert.Equal(1, childContainer.GetValue(type, "C"));
            Assert.Equal(1, childContainer.GetValue(type, "C"));

            Assert.True(childContainer.ContainsValue(type, "A", true));
            container.RemoveValue(type, "A", true);
            Assert.False(childContainer.ContainsValue(type, "A", true));

            index = 0;
            container.AddValue(type, "D", lmp => ++index);
            Assert.Equal(1, childContainer.GetValue(type, "D"));
            Assert.Equal(2, container.GetValue(type, "D"));

        }
Esempio n. 4
0
        public void Value_Test1()
        {
            var container = new IocContainer();
            container.AddValue("A", 15);
            Assert.Equal(15, container.GetValue("A"));

            int index = 0;
            container.AddValue("B", lmp => ++index);
            Assert.Equal(1, container.GetValue("B"));
            Assert.Equal(2, container.GetValue("B"));
            index = 0;

            container.AddValue("C", lmp => ++index, true);

            Assert.Equal(1, container.GetValue("C"));
            Assert.Equal(1, container.GetValue("C"));

            Assert.True(container.ContainsValue("A"));
            container.RemoveValue("A");
            Assert.False(container.ContainsValue("A"));
        }