コード例 #1
0
ファイル: OpenActionTests.cs プロジェクト: Jamiras/Core
        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
ファイル: OpenActionTests.cs プロジェクト: Jamiras/Core
        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
ファイル: OpenActionTests.cs プロジェクト: Jamiras/Core
        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
ファイル: OpenActionTests.cs プロジェクト: Jamiras/Core
        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
ファイル: OpenActionTests.cs プロジェクト: Jamiras/Core
 public void TestCreateOpenActionArgumentNull()
 {
     Assert.That(() => OpenAction.CreateOpenAction((Action <int>)null), Throws.InstanceOf <ArgumentNullException>());
 }