Пример #1
0
        public void FromMethodInfo_DoesNotAllow_AsyncVoid_Steps()
        {
            //arrange.
            var featureInstance         = new FeatureWithAsyncVoidStep();
            var methodInfoWithAsyncVoid = typeof(FeatureWithAsyncVoidStep).GetMethod(nameof(FeatureWithAsyncVoidStep.StepWithAsyncVoid));

            //act / assert.
            Assert.Throws <InvalidOperationException>(() => MethodInfoWrapper.FromMethodInfo(methodInfoWithAsyncVoid, featureInstance));
        }
Пример #2
0
        public void GetMethodName_Returns_Wrapped_Method_Name()
        {
            //arrange.
            var target = new ClassWithMethod();
            var sut    = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCall)), target);

            //act.
            var name = sut.GetMethodName();

            //assert.
            Assert.Equal(nameof(ClassWithMethod.MethodToCall), name);
        }
Пример #3
0
        public async Task InvokeMethod_Invokes_Underlying_Async_Method()
        {
            //arrange.
            var target = new ClassWithMethod();
            var sut    = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCallAsync)), target);

            //act.
            await sut.InvokeMethodAsync(null);

            //assert.
            Assert.True(target.Called);
        }
Пример #4
0
        public void IsSameAs_Identifies_Similar_Instances()
        {
            //arrange.
            var target = new ClassWithMethod();
            var sut    = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCall)), target);
            var other  = MethodInfoWrapper.FromMethodInfo(target.GetType().GetMethod(nameof(ClassWithMethod.MethodToCall)), target);

            //act.
            var same = sut.IsSameAs(other) && other.IsSameAs(sut);

            //assert.
            Assert.True(same);
        }