Exemple #1
0
        public void CanParse_CheckIncomingDataCorrectly(string fileName, bool expectedCanParse)
        {
            var stream = GetEmbeddedFileStream(fileName);
            var parser = new AquaCalcCsvParser(stream);

            Assert.That(parser.CanParse(), Is.EqualTo(expectedCanParse));
        }
        public ParseFileResult ParseFile(Stream fileStream, LocationInfo targetLocation,
                                         IFieldDataResultsAppender appender, ILog logger)
        {
            var parser = new AquaCalcCsvParser(fileStream)
            {
                Settings = appender.GetPluginConfigurations()
            };

            if (!parser.CanParse())
            {
                return(ParseFileResult.CannotParse());
            }

            var parsedData = parser.Parse();

            if (targetLocation == null)
            {
                targetLocation = appender.GetLocationByIdentifier(parsedData.GageId);
            }

            var visitDetails = new VisitMapper(parsedData).GetVisitDetails(targetLocation.UtcOffset);

            logger.Info($"Got visit details: '{visitDetails.StartDate:s}@{targetLocation.LocationIdentifier}'");

            var visitInfo = appender.AddFieldVisit(targetLocation, visitDetails);

            AppendActivity(appender, parsedData, visitInfo, logger);

            return(ParseFileResult.SuccessfullyParsedAndDataValid());
        }