public void Partner2Validator_WhenPasingInvalidDevices_ShouldReturnFalse() { // Arrange var partnerData = new Partner2(); // Act var isValid = Partner2Validator.HasValidDevices(partnerData); // Assert Assert.IsFalse(isValid); }
public void Partner2Validator_WhenPasingValidDevices_ShouldReturnTrue() { // Arrange var partnerData = new Partner2() { Devices = new List <Device>() }; // Act var isValid = Partner2Validator.HasValidDevices(partnerData); // Assert Assert.IsTrue(isValid); }
public List <TrackerDataModel> ParseJsonFile(string fileName) { var trackerData = GetPartnerfromFile <Partner2>(fileName); if (!Partner2Validator.HasValidCompany(trackerData) || !Partner2Validator.HasValidDevices(trackerData)) { throw new Exception("Bad Json File Passed In"); } var output = new List <TrackerDataModel>(); foreach (var item in trackerData.Devices) { var sensorDataDates = GetAllDatesFromDevice(item); var firstCrumbDtm = sensorDataDates.Min(); var lastCrumbDtm = sensorDataDates.Max(); var tempCount = GetCountByName(item, Tempature); var avgTemp = GetAverageByName(item, Tempature); var humidityCount = GetCountByName(item, Humidty); var avgHumidity = GetAverageByName(item, Humidty); var model = new TrackerDataModel() { CompanyId = trackerData.CompanyId, CompanyName = trackerData.Company, TrackerId = (item.DeviceID > 0) ? item.DeviceID : null, TrackerName = item.Name, StartDate = item.StartDateTime.ParseDateTimeNull(), FirstCrumbDtm = firstCrumbDtm, LastCrumbDtm = lastCrumbDtm, TempCount = tempCount, AvgTemp = avgTemp, HumidityCount = humidityCount, AvgHumidity = avgHumidity }; output.Add(model); } return(output); }