示例#1
0
        public void TestForcedParameterConstruction()
        {
            binder.Bind <ClassWithConstructorParametersOnlyOneConstructor> ().To <ClassWithConstructorParametersOnlyOneConstructor> ();
            binder.Bind <string> ().ToValue("Zaphod");
            ClassWithConstructorParametersOnlyOneConstructor instance =
                binder.GetInstance <ClassWithConstructorParametersOnlyOneConstructor> () as ClassWithConstructorParametersOnlyOneConstructor;

            Assert.IsNotNull(instance);
            Assert.That(instance.stringVal == "Zaphod");
        }
示例#2
0
		public void TestValueMappingWithConstructorArguments()
		{
			string stringVal = "Ender Wiggin";
			ClassWithConstructorParametersOnlyOneConstructor instance = new ClassWithConstructorParametersOnlyOneConstructor (stringVal);
			binder.Bind<ClassWithConstructorParametersOnlyOneConstructor> ().ToValue (instance);
			//If this class attempts to construct, with no string mapped, there'll be an error
			ClassWithConstructorParametersOnlyOneConstructor instance2 = binder.GetInstance<ClassWithConstructorParametersOnlyOneConstructor> () as ClassWithConstructorParametersOnlyOneConstructor;
			Assert.AreSame (instance, instance2);
			Assert.AreEqual (stringVal, instance2.stringVal);
		}
示例#3
0
        public void TestValueMappingWithConstructorArguments()
        {
            string stringVal = "Ender Wiggin";
            ClassWithConstructorParametersOnlyOneConstructor instance = new ClassWithConstructorParametersOnlyOneConstructor(stringVal);

            binder.Bind <ClassWithConstructorParametersOnlyOneConstructor> ().ToValue(instance);
            //If this class attempts to construct, with no string mapped, there'll be an error
            ClassWithConstructorParametersOnlyOneConstructor instance2 = binder.GetInstance <ClassWithConstructorParametersOnlyOneConstructor> () as ClassWithConstructorParametersOnlyOneConstructor;

            Assert.AreSame(instance, instance2);
            Assert.AreEqual(stringVal, instance2.stringVal);
        }