Пример #1
0
        public void ShouldWorkForNullInstances()
        {
            var container = new Container();

            ContainerExtensions.Inject(container, new TestClass());
            container.Inject <TestClass2>(null);

            var instance = container.Resolve <TestClass3>();
        }
Пример #2
0
        public void ShouldWorkForTheDefaultType()
        {
            var container = new Container();
            var testClass = new TestClass();

            ContainerExtensions.Inject(container, testClass);

            var instance = container.Resolve <TestClass>();

            Assert.AreSame(testClass, instance);
        }
Пример #3
0
        public void ShouldRemoveInstances2()
        {
            var container = new Container();
            var class1    = new ClassA1();
            var class2    = new ClassA1();

            ContainerExtensions.Inject(container, class1);

            container.RemoveAllRegistrationsAndInstancesOf <ClassA1>();

            ContainerExtensions.Inject(container, class2);

            var classA1 = container.Resolve <ClassA1>();

            Assert.AreSame(class2, classA1);
        }