public static void PropertyIndexerWithRefStructArg_ThrowsNSE() { PropertyInfo pi = typeof(TestClassWithIndexerWithRefStructArg).GetProperty("Item"); Assert.NotNull(pi); object obj = new TestClassWithIndexerWithRefStructArg(); object[] args = new object[] { null }; Assert.Throws <NotSupportedException>(() => pi.GetValue(obj, args)); Assert.Throws <NotSupportedException>(() => pi.SetValue(obj, 42, args)); }
public static void PropertyIndexerWithRefStructArg_DoesNotCopyValueBack() { PropertyInfo pi = typeof(TestClassWithIndexerWithRefStructArg).GetProperty("Item"); Assert.NotNull(pi); object obj = new TestClassWithIndexerWithRefStructArg(); object[] args = new object[] { null }; object retVal = pi.GetValue(obj, args); Assert.Equal(42, retVal); Assert.Null(args[0]); // no value should have been copied back pi.SetValue(obj, 42, args); Assert.Null(args[0]); // no value should have been copied back }