示例#1
0
        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);
        }
示例#2
0
        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>());
        }
示例#3
0
        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));
        }
示例#4
0
        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));
        }
示例#5
0
 public void TestCreateOpenActionArgumentNull()
 {
     Assert.That(() => OpenAction.CreateOpenAction((Action <int>)null), Throws.InstanceOf <ArgumentNullException>());
 }