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"); }
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); }
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); }