public void BeforeTest()
        {
            _fixture = new Fixture();

            SetupMockAppender();

            _mockLogger    = Substitute.For <ILog>();
            _csvDataPlugin = new StageDischargeReadingsPlugin(new CsvDataParser <StageDischargeReadingRecord>());
        }
        public void ParseFile_WithNoRecords_ReturnsError()
        {
            var mockCsvDataParser = Substitute.For <IDataParser <StageDischargeReadingRecord> >();

            mockCsvDataParser.ParseInputData(Arg.Any <Stream>()).Returns((IEnumerable <StageDischargeReadingRecord>)null);
            var plugin = new StageDischargeReadingsPlugin(mockCsvDataParser);

            using (var stream = new MemoryStream(Encoding.ASCII.GetBytes("Nothing to see here folks...")))
            {
                var results = plugin.ParseFile(stream, _mockAppender, _mockLogger);

                results.Status.Should().Be(ParseFileStatus.CannotParse);
                results.ErrorMessage.Should().Contain(StageDischargeReadingsPlugin.NoRecordsInInputFile);
            }
        }
        public void ParseFile_WithSomeInvalidRecords_ReturnsError()
        {
            var mockCsvDataParser = Substitute.For <IDataParser <StageDischargeReadingRecord> >();

            mockCsvDataParser.ParseInputData(Arg.Any <Stream>()).Returns(_fixture.Create <IEnumerable <StageDischargeReadingRecord> >());
            mockCsvDataParser.Errors.Returns(_fixture.CreateMany <string>().ToArray());
            mockCsvDataParser.ValidRecords.Returns(1);
            var plugin = new StageDischargeReadingsPlugin(mockCsvDataParser);

            using (var stream = new MemoryStream(Encoding.ASCII.GetBytes("Good and bad data")))
            {
                var results = plugin.ParseFile(stream, _mockAppender, _mockLogger);
                results.Status.Should().Be(ParseFileStatus.SuccessfullyParsedButDataInvalid);
                results.ErrorMessage.Should().Contain(StageDischargeReadingsPlugin.InputFileContainsInvalidRecords);
            }
        }