private async Task <IActionResult> DeleteDevice(DeleteDeviceByIdRequest deleteDeviceRequest) { var options = new DbContextOptionsBuilder <Context>() .UseInMemoryDatabase(databaseName: "Device") .Options; // Run the test against one instance of the context using (var context = new Context(options)) { var repository = new DeviceRepository(context, AutomapperSingleton.Mapper); var service = new DeviceService(repository, AutomapperSingleton.Mapper); var controller = new DeviceController(service); Mock <HttpRequest> mockCreateRequest = MockHttpRequest.CreateMockQuery(deleteDeviceRequest.Id); return(await controller.DeleteDeviceAsync(mockCreateRequest.Object, _logger)); //as GridController; } }