public void TestUnsupply()
        {
            Binder.BindingResolver resolver = delegate(IBinding bound)
            {
            };
            InjectionBinding binding = new InjectionBinding(resolver);

            binding.To <ClassToBeInjected>().SupplyTo <HasANamedInjection> ();
            Assert.AreEqual(typeof(HasANamedInjection), binding.GetSupply()[0]);
            Assert.AreEqual(typeof(ClassToBeInjected), binding.value);

            binding.Unsupply <HasANamedInjection> ();
            Assert.IsNull(binding.GetSupply());
        }
        public void TestGetSupply()
        {
            Type[] supplied = new Type[3];
            supplied [0] = typeof(HasANamedInjection);
            supplied [1] = typeof(HasANamedInjection2);
            supplied [2] = typeof(InjectsClassToBeInjected);
            int iterator = 0;

            Binder.BindingResolver resolver = delegate(IBinding bound)
            {
                object[] value = (bound as IInjectionBinding).GetSupply();
                Assert.AreEqual(value[value.Length - 1], supplied[iterator]);
            };

            InjectionBinding binding = new InjectionBinding(resolver);

            while (iterator < 3)
            {
                binding.SupplyTo(supplied[iterator]);
                iterator++;
            }

            object[] supply = binding.GetSupply();
            Assert.AreEqual(3, supply.Length);

            for (var a = 0; a < supply.Length; a++)
            {
                Assert.AreEqual(supply[a], supplied[a]);
            }
        }
示例#3
0
		public void TestGetSupply()
		{
			Type[] supplied = new Type[3];
			supplied [0] = typeof (HasANamedInjection);
			supplied [1] = typeof (HasANamedInjection2);
			supplied [2] = typeof (InjectsClassToBeInjected);
			int iterator = 0;

			Binder.BindingResolver resolver = delegate (IBinding bound)
			{
				object[] value = (bound as IInjectionBinding).GetSupply();
				Assert.AreEqual(value[value.Length-1], supplied[iterator]);
			};

			InjectionBinding binding = new InjectionBinding (resolver);

			while (iterator < 3)
			{
				binding.SupplyTo (supplied[iterator]);
				iterator++;
			}

			object[] supply = binding.GetSupply ();
			Assert.AreEqual (3, supply.Length);

			for (var a = 0; a < supply.Length; a++)
			{
				Assert.AreEqual (supply[a], supplied[a]);
			}
		}
示例#4
0
		public void TestUnsupply()
		{
			Binder.BindingResolver resolver = delegate (IBinding bound)
			{
			};
			InjectionBinding binding = new InjectionBinding (resolver);
			binding.To<ClassToBeInjected>().SupplyTo<HasANamedInjection> ();
			Assert.AreEqual (typeof(HasANamedInjection), binding.GetSupply()[0]);
			Assert.AreEqual (typeof(ClassToBeInjected), binding.value);

			binding.Unsupply<HasANamedInjection> ();
			Assert.IsNull (binding.GetSupply());
		}