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(); }
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); }
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); }
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(); }
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); }