예제 #1
0
        public void Test2InterfacesContainerBindingPersistence()
        {
            IDIContext      context     = ContextHelper.CreateContext();
            SingletonBinder modelBinder = new SingletonBinder(context);

            modelBinder.BindMany <IAdvancedRead, IAdvancedWrite>(() => new AdvancedModel());

            SingletoneCreation(context);
            IAdvancedRead read = context.Resolve <IAdvancedRead>();

            Assert.That(read is AdvancedModel);
            Assert.AreEqual("my_test_model", read.tag);
        }
예제 #2
0
        public void TestCreationByNewFactory()
        {
            IDIContext context = ContextHelper.CreateContext();

            // Then let's create a standard factory we will use
            SingletonBinder binder = new SingletonBinder(context);

            // Let's bind a test type using our factory
            binder.Bind <IDependencyTest>(() => new DependencyTest());

            // Let's see that the dependencies are now injected - this class has injected context
            IDependencyTest test = context.Resolve <IDependencyTest>();

            Assert.IsNotNull(test.contextAccess);
        }