public void GetArgumentValue() { ConstructorArgumentValues values = new ConstructorArgumentValues(); Assert.IsNull(values.GetArgumentValue(0, typeof(object)), "Mmm... managed to get a non null instance back from an empty instance."); values.AddGenericArgumentValue(DBNull.Value, typeof(DBNull).FullName); values.AddNamedArgumentValue("foo", DBNull.Value); values.AddIndexedArgumentValue(16, DBNull.Value, typeof(DBNull).FullName); Assert.IsNull(values.GetArgumentValue(100, typeof(string)), "Mmm... managed to get a non null instance back from an instance that should have now't with the specified Type."); ConstructorArgumentValues.ValueHolder value = values.GetArgumentValue(-3, typeof(DBNull)); Assert.IsNotNull(value, "Stored a value of a specified Type at a specified index, but got null when retrieving it using the wrong index but the correct Type."); Assert.AreSame(DBNull.Value, value.Value, "The retrieved value was not the exact same instance as was added."); value = values.GetArgumentValue("foo", typeof(DBNull)); Assert.IsNotNull(value, "Stored a value of a specified Type under a name, but got null when retrieving it using the wrong name but the correct Type."); Assert.AreSame(DBNull.Value, value.Value, "The retrieved value was not the exact same instance as was added."); }
public void GetArgumentValueIgnoresAlreadyUsedValues() { ISet used = new ListSet(); ConstructorArgumentValues values = new ConstructorArgumentValues(); values.AddGenericArgumentValue(1); values.AddNamedArgumentValue("2", 2); values.AddIndexedArgumentValue(3, 3); Type intType = typeof(int); ConstructorArgumentValues.ValueHolder one = values.GetArgumentValue(10, string.Empty, intType, used); Assert.AreEqual(1, one.Value); used.Add(one); ConstructorArgumentValues.ValueHolder two = values.GetArgumentValue(10, "2", intType, used); Assert.AreEqual(2, two.Value); used.Add(two); ConstructorArgumentValues.ValueHolder three = values.GetArgumentValue(3, string.Empty, intType, used); Assert.AreEqual(3, three.Value); used.Add(three); ConstructorArgumentValues.ValueHolder four = values.GetArgumentValue(10, string.Empty, intType, used); Assert.IsNull(four); }