Esempio n. 1
0
        public void Partner1Validator_WhenPasingInvalidTrackers_ShouldReturnFalse()
        {
            // Arrange
            var partnerData = new Partner1();


            // Act
            var isValid = Partner1Validator.HasValidTrackers(partnerData);


            // Assert
            Assert.IsFalse(isValid);
        }
Esempio n. 2
0
        public void Partner1Validator_WhenPasingValidTrackers_ShouldReturnTrue()
        {
            // Arrange
            var partnerData = new Partner1()
            {
                Trackers = new List <Tracker>()
            };


            // Act
            var isValid = Partner1Validator.HasValidTrackers(partnerData);


            // Assert
            Assert.IsTrue(isValid);
        }
Esempio n. 3
0
        public List <TrackerDataModel> ParseJsonFile(string fileName)
        {
            var trackerData = GetPartnerfromFile <Partner1>(fileName);

            if (!Partner1Validator.HasValidPartnerName(trackerData) ||
                !Partner1Validator.HasValidTrackers(trackerData))
            {
                throw new Exception("Bad Json File Passed In");
            }

            var output = new List <TrackerDataModel>();

            foreach (var item in trackerData.Trackers)
            {
                var crumbsDates   = GetAllDatesFromCrumbs(item);
                var firstCrumbDtm = crumbsDates.Min();
                var lastCrumbDtm  = crumbsDates.Max();

                var tempCount = GetCountByName(item, Temperature);
                var avgTemp   = GetAverageByName(item, Temperature);

                var humidityCount = GetCountByName(item, Humidty);
                var avgHumidity   = GetAverageByName(item, Humidty);

                var model = new TrackerDataModel()
                {
                    CompanyId     = trackerData.PartnerId,
                    CompanyName   = trackerData.PartnerName,
                    TrackerId     = (item.Id > 0) ? item.Id : null,
                    TrackerName   = item.Model,
                    StartDate     = item.ShipmentStartDtm.ParseDateTimeNull(),
                    FirstCrumbDtm = firstCrumbDtm,
                    LastCrumbDtm  = lastCrumbDtm,
                    TempCount     = tempCount,
                    AvgTemp       = avgTemp,
                    HumidityCount = humidityCount,
                    AvgHumidity   = avgHumidity
                };
                output.Add(model);
            }

            return(output);
        }