public void GetMeasurementStatistic_Statistics() { // Arrange MeasurementsController measurementController = new MeasurementsController(); // Act MeasurementsRepository.ClearAllMeasurements(); var fromtimeValue = DateTime.UtcNow; MockData.SaveMeasurement(fromtimeValue.ToString()); var totimeValue = DateTime.UtcNow.AddSeconds(3); MockData.SaveMeasurement(totimeValue.ToString()); var response = measurementController.GetMeasurementStatistics(MockData.PrepareMetricData(), MockData.PrepareStatsData(), fromtimeValue.ToString(), totimeValue.ToString()); var actualResponse = response as OkNegotiatedContentResult <IList <Statistic> >; var returnResponse = (IList <Statistic>)actualResponse.Content; //Assert Assert.IsNotNull(response); Assert.IsTrue(returnResponse.Count > 1, "It should contain statistics "); }
public void GetMeasurementStatistic_NoData_Statistics() { // Arrange MeasurementsController measurementController = new MeasurementsController(); // Act MeasurementsRepository.ClearAllMeasurements(); var fromtimeValue = DateTime.UtcNow; MockData.SaveMeasurement(fromtimeValue.ToString()); var totimeValue = DateTime.UtcNow.AddSeconds(3); MockData.SaveMeasurement(totimeValue.ToString()); var response = measurementController.GetMeasurementStatistics(MockData.PrepareMetricData(), MockData.PrepareStatsData(), fromtimeValue.AddDays(1).ToString(), totimeValue.AddDays(3).ToString()); var actualResponse = response as OkNegotiatedContentResult <String>; //Assert Assert.IsNotNull(actualResponse); Assert.AreEqual(actualResponse.Content, "No Data available"); }
public void GetMeasurementsForTime_ProperData_ForDate() { // Arrange MeasurementsController measurementController = new MeasurementsController(); // Act MeasurementsRepository.ClearAllMeasurements(); var timeValue = DateTime.UtcNow.ToString(); MockData.SaveMeasurement(timeValue); var response = measurementController.GetMeasurementsForTime(timeValue); var actualResponse = response as OkNegotiatedContentResult <IList <Measurement> >; var returnValue = actualResponse.Content as IList <Measurement>; //Assert Assert.IsNotNull(actualResponse); Assert.IsTrue(returnValue.Count == 1, "Return value should be 1 because Added one measurement."); }
public void GetMeasurementStatistic_fromtimeValue_RestNullValues() { // Arrange MeasurementsController measurementController = new MeasurementsController(); // Act var fromtimeValue = DateTime.UtcNow; MockData.SaveMeasurement(fromtimeValue.ToString()); var totimeValue = DateTime.UtcNow.AddSeconds(3); MockData.SaveMeasurement(totimeValue.ToString()); var response = measurementController.GetMeasurementStatistics(null, null, fromtimeValue.ToString(), null); var actualResponse = response as BadRequestErrorMessageResult; //Assert Assert.IsNotNull(actualResponse); Assert.AreEqual(actualResponse.Message, "Parameters are not valid"); }
public void GetMeasurementsForTime_InRange_ForDate() { // Arrange MeasurementsController measurementController = new MeasurementsController(); // Act MeasurementsRepository.ClearAllMeasurements(); var fromtimeValue = DateTime.UtcNow; MockData.SaveMeasurement(fromtimeValue.ToString()); var totimeValue = DateTime.UtcNow.AddSeconds(3); MockData.SaveMeasurement(totimeValue.ToString()); var response = measurementController.GetMeasurementsForTime(fromtimeValue.ToString(), null); var actualResponse = response as OkNegotiatedContentResult <IList <Measurement> >; var returnValue = actualResponse.Content as IList <Measurement>; //Assert Assert.IsNotNull(actualResponse); Assert.IsTrue(returnValue.Count == 2, "Return value should be 2 because Added 2 measurement with in time range"); }
public void GetMeasurementsForTime_NoValue_ForDate() { // Arrange MeasurementsController measurementController = new MeasurementsController(); // Act MeasurementsRepository.ClearAllMeasurements(); var fromtimeValue = DateTime.UtcNow; MockData.SaveMeasurement(fromtimeValue.ToString()); var totimeValue = DateTime.UtcNow.AddSeconds(3); MockData.SaveMeasurement(totimeValue.ToString()); var response = measurementController.GetMeasurementsForTime(fromtimeValue.ToString(), totimeValue.AddHours(1).ToString()); var actualResponse = response as NotFoundResult; //Assert Assert.IsNotNull(actualResponse); }