public void ShouldApplyMapperConfigurationsInOrderAutomatically() { var values = new List <int> { 1, 2, 3 }; var provider = new StubServiceProvider(values); var grandParent = new GrandParent { DatChild = new Parent { MyChild = new Child() } }; using (var mapper = Mapper.CreateNew()) { mapper.WhenMapping .UseServiceProvider(provider) .UseConfigurations .From <GrandParentMapperConfiguration>(); var result = mapper.Map(grandParent).ToANew <GrandParentDto>(); result.MyChild.ShouldNotBeNull(); result.MyChild.MyChild.ShouldNotBeNull(); result.MyChild.MyChild.IsMyCountGtrZero.ShouldBeTrue(); } }
public void ReturnNullWhenExpected() { var target = new StubServiceProvider(null); var result = target.GetService <IRasApi32>(); Assert.IsNull(result); }
public async void set_remote_response_into_service() { var context = new DefaultHttpContext(); var stubProvider = new StubServiceProvider(); var mock = new Mock <IResponseProvider>(); mock.Setup(provider => provider.GetBodyAsync(It.IsAny <string>())) .ReturnsAsync("test body"); stubProvider.AppendService(typeof(IResponseProvider), mock.Object); context.RequestServices = stubProvider; context.Request.Path = new PathString("/me"); var options = new ModularApplicationMiddlewareOptions { Endpoints = new Dictionary <string, string> { { "me", "http://localhost:5001" } } }; var middleware = new ModularApplicationMiddleware((innerHttpContext) => { return(Task.CompletedTask); }, options); await middleware.Invoke(context); }
public void RetrievesTheObjectForTheGenericTypeSpecified() { var result = new Mock <IRasApi32>(); var target = new StubServiceProvider(result.Object); var actual = target.GetService <IRasApi32>(); Assert.AreEqual(result.Object, actual); }
public void ThrowsAnExceptionWhenTheServiceIsNotFoundWhenRequired() { var serviceProvider = new StubServiceProvider(null); Assert.Throws <InvalidOperationException>(() => serviceProvider.GetRequiredService <IRasApi32>()); }
public void ThrowsAnExceptionWhenServiceTypeIsNull() { var serviceProvider = new StubServiceProvider(null); Assert.Throws <ArgumentNullException>(() => serviceProvider.GetRequiredService(null)); }