public async Task DevicesController_GetDataForDevice_Tests() { //Valid Tests serviceMock.Setup(t => t.GetDeviceDataAsync(It.IsAny <string>(), It.IsAny <DateTime>())).ReturnsAsync(new List <SensorData>()); var result = await controller.GetDataForDevice("deviceId", DateTime.Now); var actionResult = Assert.IsType <OkObjectResult>(result); Assert.IsType <List <SensorData> >(actionResult.Value); //Invalid Tests result = await controller.GetDataForDevice("deviceId", DateTime.Now.AddDays(1)); Assert.IsType <BadRequestObjectResult>(result); }