Пример #1
0
        public void WriteFile_150000Customers_150000BatchSize_DuplicatesLeft()
        {
            // Arrange
            var                    batchCSVWriter  = this.CreateBatchCSVWriter(new LeaveDuplicates());
            string                 filename        = "BatchTest";
            TestDataFactory        testDataFactory = new TestDataFactory();
            IEnumerable <Customer> customers       = testDataFactory.GenerateCustomers(150000);
            int                    batchSize       = 150000;

            // Act
            batchCSVWriter.WriteFile(
                filename,
                customers,
                batchSize);

            // Assert
            _subCsvWriter.Received(1).WriteFile(Arg.Any <string>(), Arg.Any <List <Customer> >());
        }
Пример #2
0
        public void Should_Open_Writer_When_Mode_Is_Write()
        {
            //Arrange
            _csvReader       = Substitute.For <ICSVReader>();
            _csvWriter       = Substitute.For <ICSVWriter>();
            _csvReaderWriter = new CSVReaderWriter(_csvReader, _csvWriter);

            //Act
            _csvReaderWriter.Open(FilePath, CSVReaderWriter.Mode.Write);

            //Assert
            _csvWriter.Received().Open(FilePath);
            _csvReader.DidNotReceive().Open(FilePath);
        }
Пример #3
0
        public void Should_Dispose_Resources_When_Closed()
        {
            //Arrange
            _csvReader       = Substitute.For <ICSVReader>();
            _csvWriter       = Substitute.For <ICSVWriter>();
            _csvReaderWriter = new CSVReaderWriter(_csvReader, _csvWriter);

            //Act
            _csvReaderWriter.Open(FilePath, CSVReaderWriter.Mode.Read);
            _csvReaderWriter.Close();

            //Assert
            _csvReader.Received().Dispose();
            _csvWriter.Received().Dispose();
        }
Пример #4
0
        public void Should_Write_Line_When_Columns_Are_Written()
        {
            //Arrange
            _csvReader       = Substitute.For <ICSVReader>();
            _csvWriter       = Substitute.For <ICSVWriter>();
            _csvReaderWriter = new CSVReaderWriter(_csvReader, _csvWriter);

            //Act
            _csvReaderWriter.Open(FilePath, CSVReaderWriter.Mode.Write);
            string[] columns = new string[] { Name, Address };
            _csvReaderWriter.Write(columns);

            //Assert
            _csvWriter.Received().Write(columns);
        }