public static MemoryStream CreateCsvFile(IFixture fixture)
        {
            InMemoryCsvFile <StageDischargeReadingRecord> csvFile = new InMemoryCsvFile <StageDischargeReadingRecord>();

            csvFile.AddRecord(CreateFullRecord(fixture));
            return(csvFile.GetInMemoryCsvFileStream());
        }
        private Stream CreateMemoryStream(StageDischargeReadingRecord originalRecord)
        {
            var csvFile = new InMemoryCsvFile <StageDischargeReadingRecord>();

            csvFile.AddRecord(originalRecord);
            return(csvFile.GetInMemoryCsvFileStream());
        }
        private InMemoryCsvFile <DummyImportRecord> CreateDummyImportFile(DummyImportRecordBuilder recordBuilder, int rowCount = 5)
        {
            var importFile = new InMemoryCsvFile <DummyImportRecord>();

            for (var i = 0; i < rowCount; i++)
            {
                importFile.AddRecord(recordBuilder.AParametricRecord(i));
            }
            return(importFile);
        }
 private void PutNRecordsInCsvFile(int recordCount, ref InMemoryCsvFile <StageDischargeReadingRecord> csvFile)
 {
     for (var i = 0; i < recordCount; i++)
     {
         StageDischargeReadingRecord rRecord = _fixture.Build <StageDischargeReadingRecord>()
                                               .With(x => x.MeasurementStartDateTime, DateTime.Now.AddHours(i))
                                               .With(x => x.MeasurementEndDateTime, DateTime.Now.AddHours(i * 2))
                                               .Without(x => x.Readings)
                                               .Create();
         csvFile.AddRecord(rRecord);
     }
 }
        public void ParseFile_WithFiveValidRowsInCsvInputFile_ReadsAndSavesAndReturnsSuccess()
        {
            var csvFile = new InMemoryCsvFile <StageDischargeReadingRecord>();

            PutNRecordsInCsvFile(5, ref csvFile);

            using (var stream = csvFile.GetInMemoryCsvFileStream())
            {
                _mockAppender.GetLocationByIdentifier(Arg.Any <string>())
                .Returns(LocationInfoHelper.GetTestLocationInfo(_fixture),
                         LocationInfoHelper.GetTestLocationInfo(_fixture),
                         LocationInfoHelper.GetTestLocationInfo(_fixture),
                         LocationInfoHelper.GetTestLocationInfo(_fixture),
                         LocationInfoHelper.GetTestLocationInfo(_fixture));

                var results = _csvDataPlugin.ParseFile(stream, _mockAppender, _mockLogger);

                results.Status.Should().NotBe(ParseFileStatus.CannotParse, results.ErrorMessage);
                results.Status.Should().Be(ParseFileStatus.SuccessfullyParsedAndDataValid);

                _mockAppender.Received().AddFieldVisit(Arg.Any <LocationInfo>(), Arg.Any <FieldVisitDetails>());
                _mockAppender.Received(5).AddDischargeActivity(Arg.Any <FieldVisitInfo>(), Arg.Any <DischargeActivity>());
            }
        }