Пример #1
0
        public void ShouldInvokeTheSpecifiedMethod()
        {
            IFakeInterface instance = Substitute.For <IFakeInterface>();

            RouteMethod result = this.adapter.CreateMethod(
                () => instance,
                typeof(IFakeInterface).GetMethod(nameof(IFakeInterface.SimpleMethod)));

            result(null);
            instance.Received().SimpleMethod();
        }
Пример #2
0
        public void ShouldPassInTheTypesDefaultValueForParametersMarkedAsOptional()
        {
            IFakeInterface instance = Substitute.For <IFakeInterface>();

            RouteMethod result = this.adapter.CreateMethod(
                () => instance,
                typeof(IFakeInterface).GetMethod(nameof(IFakeInterface.NonDefaultedOptions)));

            result(new Dictionary <string, object>());

            instance.Received().NonDefaultedOptions(0);
        }
Пример #3
0
        public void ShouldPassInDefaultedValuesForOptionalParametersWithDefaults()
        {
            IFakeInterface instance = Substitute.For <IFakeInterface>();

            RouteMethod result = this.adapter.CreateMethod(
                () => instance,
                typeof(IFakeInterface).GetMethod(nameof(IFakeInterface.OptionalParameter)));

            result(new Dictionary <string, object>());

            instance.Received().OptionalParameter(321);
        }
Пример #4
0
        public async Task ShouldReturnNoContentValueForTaskMethods()
        {
            IFakeInterface instance = Substitute.For <IFakeInterface>();

            RouteMethod wrapper = this.adapter.CreateMethod(
                () => instance,
                typeof(IFakeInterface).GetMethod(nameof(IFakeInterface.TaskMethod)));

            object result = await wrapper(null);

            Assert.That(result, Is.SameAs(NoContent.Value));
            await instance.Received().TaskMethod();
        }
Пример #5
0
        public void ShouldPassInTheCapturedValueForOptionalParameters()
        {
            IFakeInterface instance = Substitute.For <IFakeInterface>();

            RouteMethod result = this.adapter.CreateMethod(
                () => instance,
                typeof(IFakeInterface).GetMethod(nameof(IFakeInterface.OptionalParameter)));

            result(new Dictionary <string, object> {
                { "optional", 123 }
            });

            instance.Received().OptionalParameter(123);
        }