public void InstantiateWithNullObjectName() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object obj = strategy.Instantiate(SingletonDefinition, null, Factory); Assert.IsNotNull(obj); Assert.IsTrue(obj is ITestObject); ITestObject actual = (ITestObject) obj; Assert.IsNull(actual.Name); Assert.AreEqual(0, actual.Age); }
public void InstantiateWithNullObjectName() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object obj = strategy.Instantiate(SingletonDefinition, null, Factory); Assert.IsNotNull(obj); Assert.IsTrue(obj is ITestObject); ITestObject actual = (ITestObject)obj; Assert.IsNull(actual.Name); Assert.AreEqual(0, actual.Age); }
public void InstantiateWithDefinitionThatDoesNotHaveAResolvedObjectClass() { RootObjectDefinition def = new RootObjectDefinition(); def.ObjectTypeName = typeof(TestObject).FullName; SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object foo = strategy.Instantiate(def, "foo", Factory); Assert.IsNotNull(foo); Assert.AreEqual(typeof(TestObject), foo.GetType()); }
public void InstantiateWithFactoryMethod() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object obj = strategy.Instantiate(SingletonDefinitionWithFactory, string.Empty, Factory, typeof(TestObjectFactory).GetMethod("GetObject"), null); Assert.IsNotNull(obj); Assert.IsTrue(obj is ITestObject); ITestObject actual = (ITestObject)obj; Assert.AreEqual(TestObjectFactory.TheName, actual.Name); Assert.AreEqual(TestObjectFactory.TheAge, actual.Age); }
public void InstantiateWithExplicitCtor() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object obj = strategy.Instantiate( SingletonDefinition, null, Factory, SingletonDefinition.ObjectType.GetConstructor( new Type[] {typeof (string), typeof (int)}), new object[] {"Rick", 19}); Assert.IsNotNull(obj); Assert.IsTrue(obj is ITestObject); ITestObject actual = (ITestObject) obj; Assert.AreEqual("Rick", actual.Name); Assert.AreEqual(19, actual.Age); }
public void InstantiateWithExplicitCtor() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object obj = strategy.Instantiate( SingletonDefinition, null, Factory, SingletonDefinition.ObjectType.GetConstructor( new Type[] { typeof(string), typeof(int) }), new object[] { "Rick", 19 }); Assert.IsNotNull(obj); Assert.IsTrue(obj is ITestObject); ITestObject actual = (ITestObject)obj; Assert.AreEqual("Rick", actual.Name); Assert.AreEqual(19, actual.Age); }
public void InstantiateWithFactoryMethod() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); object obj = strategy.Instantiate(SingletonDefinitionWithFactory, string.Empty, Factory, typeof (TestObjectFactory).GetMethod("GetObject"), null); Assert.IsNotNull(obj); Assert.IsTrue(obj is ITestObject); ITestObject actual = (ITestObject) obj; Assert.AreEqual(TestObjectFactory.TheName, actual.Name); Assert.AreEqual(TestObjectFactory.TheAge, actual.Age); }
public void InstantiateWithNulls() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); Assert.Throws<ArgumentNullException>(() => strategy.Instantiate(null, null, null)); }
public void InstantiateWithNulls() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); strategy.Instantiate(null, null, null); }
public void InstantiateWithNulls() { SimpleInstantiationStrategy strategy = new SimpleInstantiationStrategy(); Assert.Throws <ArgumentNullException>(() => strategy.Instantiate(null, null, null)); }