Esempio n. 1
0
        public void Can_Single_Register_For_More_Than_One_Type()
        {
            var injector = new HrcInjector();
            const string instance = "HRC Testing";
            injector.Bind(instance);

            var result = injector.Resolve<string>();
            Assert.AreEqual(result, instance);

            const string otherInstance = "HRC Testing...";
            injector.Bind(otherInstance);

            var otherResult = injector.Resolve<string>();
            Assert.AreEqual(otherResult, otherInstance);
            Assert.AreNotEqual(otherResult, instance);
        }
Esempio n. 2
0
        public void Can_Resolve_By_Type()
        {
            var injector = new HrcInjector();
            injector.Bind<int>(666);

            var result = injector.Resolve(typeof(int));
            Assert.AreEqual(result, 666);
        }
Esempio n. 3
0
        public void Can_Do_Constructor_Injection()
        {
            var injector = new HrcInjector();
            injector.Bind<IHrcTestObject, HrcTestObject>();

            var result = injector.Resolve(typeof(IHrcTestObject));//injector.Resolve<IHrcTestObject>();
            Assert.IsAssignableFrom<IHrcTestObject>(result);
        }
Esempio n. 4
0
        public void Can_Register_Concrete_Object_For_Interface()
        {
            var injector = new HrcInjector();
            injector.Bind<IHrcInjectorTestObject, HrcInjectorTestObject2>();

            var result = injector.Resolve<IHrcInjectorTestObject>();
            Assert.AreEqual(typeof(HrcInjectorTestObject2), result.GetType());
            Assert.IsInstanceOf<IHrcInjectorTestObject>(result);
        }