public CustomerController( IMockedService mockedService, IHalEmbededResourceContext resourceContext) { _mockedService = mockedService; _resourceContext = resourceContext; }
public static IRequestClient CreateTestClient(this IRequestSettings requestSettings, MockAppHostPlugin hostPlugin, IMockedService mockService = null) { requestSettings.UseHalDefaults(); var serializers = new Dictionary <string, IMediaTypeSerializer> { { InternetMediaTypes.Json, new JsonMediaTypeSerializer() }, { InternetMediaTypes.HalJson, new JsonMediaTypeSerializer() } }; var builder = new WebHostBuilder() .ConfigureServices(services => { // Add the needed ResourcePlugin modules since this is // what the unit tests will be testing. hostPlugin.UseResourcePlugin(); // Creates the typical StartUp class used by ASP.NET Core. var startup = new TestStartup(hostPlugin); services.AddSingleton <IStartup>(startup); // This service will be injected by the WebApi controller and // can be used to very the system under test. services.AddSingleton <IMockedService>(mockService ?? new NullUnitTestService()); }); // Create an instance of the server and create an HTTP Client // to communicate with in-memory web-host. var server = new TestServer(builder); var httpClient = server.CreateClient(); // Return an instance of the ResourceClient to be tested. return(new RequestClient(httpClient, serializers, requestSettings)); }
public LinkedResourceController(IMockedService mockedService) { _mockedService = mockedService; }
public ConcreteClass(IMockedService service, IMockedService2 service2, IMockedService3 service3) { _service = service; _service2 = service2; _service3 = service3; }
public ConcreteThing(IMockedService service, IMockedService2 service2) { _service = service; _service2 = service2; }
public ErrorController(IMockedService mockedService) { _mockedService = mockedService; }
public static WebServerConfig ArrangeWithDefaults(this WebHostFixture fixture, IMockedService service = null) { return(fixture.WithServices(services => { var serviceMock = new MockUnitTestService { ServerResources = new object[] {} }; services.AddSingleton(service ?? serviceMock); }) .ComposedFrom(compose => { compose.AddRest(); var hostPlugin = new MockHostPlugin(); hostPlugin.AddPluginType <LinkedResourceMap>(); hostPlugin.AddPluginType <CustomerResourceMap>(); compose.AddPlugin(hostPlugin); })); }
public ConventionBasedController(IMockedService mockedService) { _mockedService = mockedService; }