Beispiel #1
0
        public void TestInjectOnInstance()
        {
            var mockInterface = this.binder.GetBindingsFor<IMockInterface>()[0].value;
            var singleton = this.binder.GetBindingsFor<MockIClassWithoutAttributes>()[0].value;

            var instance = new MockClassWithDependencies();
            this.injector.Inject<MockClassWithDependencies>(instance);

            Assert.AreEqual(instance.fieldMockInterface.GetType(), mockInterface);
            Assert.AreEqual(instance.fieldSingleton, singleton);
            Assert.AreEqual(instance.propertyMockInterface.GetType(), mockInterface);
            Assert.AreEqual(instance.propertySingleton, singleton);
        }
Beispiel #2
0
        public void TestInjectOnInstance()
        {
            var mockInterface = this.binder.GetBindingsFor <IMockInterface>()[0].value;
            var singleton     = this.binder.GetBindingsFor <MockIClassWithoutAttributes>()[0].value;

            var instance = new MockClassWithDependencies();

            this.injector.Inject <MockClassWithDependencies>(instance);

            Assert.AreEqual(instance.fieldMockInterface.GetType(), mockInterface);
            Assert.AreEqual(instance.fieldSingleton, singleton);
            Assert.AreEqual(instance.propertyMockInterface.GetType(), mockInterface);
            Assert.AreEqual(instance.propertySingleton, singleton);
        }