예제 #1
0
        public void TestSimpleRuntimeCommandBinding()
        {
            string jsonInjectorString = "[{\"Bind\":\"strange.unittests.ISimpleInterface\",\"To\":\"strange.unittests.SimpleInterfaceImplementer\", \"Options\":\"ToSingleton\"}]";

            injectionBinder.ConsumeBindings(jsonInjectorString);

            string jsonCommandString = "[{\"Bind\":\"strange.unittests.SomeEnum.ONE\",\"To\":\"strange.unittests.CommandWithInjection\"}]";

            commandBinder.ConsumeBindings(jsonCommandString);
            commandBinder.ReactTo(SomeEnum.ONE);

            ISimpleInterface instance = injectionBinder.GetInstance <ISimpleInterface>() as ISimpleInterface;

            Assert.AreEqual(100, instance.intValue);
        }
예제 #2
0
        public void TestRuntimeCommandWithPooling()
        {
            string jsonInjectorString = "[{\"Bind\":\"strange.unittests.ISimpleInterface\",\"To\":\"strange.unittests.SimpleInterfaceImplementer\", \"Options\":\"ToSingleton\"}]";

            injectionBinder.ConsumeBindings(jsonInjectorString);

            string jsonCommandString = "[{\"Bind\":\"TestEvent\",\"To\":\"strange.unittests.CommandWithInjection\", \"Options\":\"Pooled\"}]";

            commandBinder.ConsumeBindings(jsonCommandString);
            ICommandBinding binding = commandBinder.GetBinding("TestEvent") as ICommandBinding;

            Assert.IsTrue(binding.isPooled);
            commandBinder.ReactTo("TestEvent");

            ISimpleInterface instance = injectionBinder.GetInstance <ISimpleInterface>() as ISimpleInterface;

            Assert.AreEqual(100, instance.intValue);
        }
예제 #3
0
        public void TestSimpleRuntimeInjection()
        {
            string jsonString = "[{\"Bind\":\"strange.unittests.ISimpleInterface\",\"To\":\"strange.unittests.SimpleInterfaceImplementer\"}]";

            binder.ConsumeBindings(jsonString);

            IBinding binding = binder.GetBinding <ISimpleInterface> ();

            Assert.NotNull(binding);
            Assert.AreEqual((binding as IInjectionBinding).type, InjectionBindingType.DEFAULT);

            ISimpleInterface instance = binder.GetInstance(typeof(ISimpleInterface)) as ISimpleInterface;

            Assert.IsInstanceOf <SimpleInterfaceImplementer> (instance);
        }