public void TestCreateOpenActionStaticMethod() { Assert.That(() => OpenAction.CreateOpenAction <int>(TestClass.SetStaticValue), Throws.ArgumentException); Action <int, int> method = TestClass.SetStaticValues; Assert.That(() => OpenAction.CreateOpenAction <int, int>(method.Method), Throws.ArgumentException); }
public void TestOpenActionWrongTargetType() { var target = new TestClass(); Action <object, int> openAction = OpenAction.CreateOpenAction <int>(target.SetValue); Assert.That(openAction, Is.Not.Null, "failed to create openAction"); Assert.That(() => openAction(this, 3), Throws.InstanceOf <InvalidCastException>()); }
public void TestOpenActionTargetAsObject() { var target = new TestClass(); Action <object, int> openAction = OpenAction.CreateOpenAction <int>(target.SetValue); Assert.That(openAction, Is.Not.Null, "failed to create openAction"); openAction(target, 3); Assert.That(target.Value, Is.EqualTo(3)); }
public void TestCreateOpenActionTwoParameters() { var target = new TestClass(); Action <int, int> method = target.SetValues; Action <object, int, int> openAction = OpenAction.CreateOpenAction <int, int>(method.Method); Assert.That(openAction, Is.Not.Null, "failed to create openAction"); openAction(target, 3, 4); Assert.That(target.Value, Is.EqualTo(7)); }
public void TestCreateOpenActionArgumentNull() { Assert.That(() => OpenAction.CreateOpenAction((Action <int>)null), Throws.InstanceOf <ArgumentNullException>()); }