public async Task GetReadingsUsingDeviceId_Startingdate_WithReadingsAvailable_ReturnsReadings() { //Arrange var dbContext = DbContextMocker.GetDbContext(nameof(GetReadingsUsingDeviceId_Startingdate_WithReadingsAvailable_ReturnsReadings)); var readingsController = new ReadingsController(dbContext); var expectedReadings = new List <Reading> { }; expectedReadings.Add(new Reading() { Device_id = 1, Timestamp = 1001, Reading_type = "typeTest2", Raw_value = 20 }); expectedReadings.Add(new Reading() { Device_id = 1, Timestamp = 1002, Reading_type = "typeTest3", Raw_value = 30 }); //Act var response = await readingsController.GetReadingsUsingDeviceId_Startingdate(1, 1001); var result = (ObjectResult)response.Result; var readingsReceived = result.Value.As <List <Reading> >(); dbContext.Dispose(); //Assert result.StatusCode.Should().Be((int)HttpStatusCode.OK); Assert.True(ReadingsComparer.CompareReadingsLists(readingsReceived, expectedReadings), "Received readings list did " + "not match with the expected"); }
public async Task GetReadingsUsingDeviceId_Startingdate_WithoutAnExistingDevice_ReturnsNotFound() { //Arrange var dbContext = DbContextMocker.GetDbContext(nameof(GetReadingsUsingDeviceId_Startingdate_WithoutAnExistingDevice_ReturnsNotFound)); var readingsController = new ReadingsController(dbContext); //Act var response = await readingsController.GetReadingsUsingDeviceId_Startingdate(5, 1001); var result = (ObjectResult)response.Result; var readingsReceived = result.Value.As <List <Reading> >(); dbContext.Dispose(); //Assert result.StatusCode.Should().Be((int)HttpStatusCode.NotFound); }