Ejemplo n.º 1
0
        public void CreateCSVFile_GivenFileNameAndManyCustomers_ShouldSaveManyContacts()
        {
            // Arrange
            var customers = Builder <Customer> .CreateListOfSize(12).Build();

            var fileSystem       = Substitute.For <IFileSystem>();
            var dublicates       = Substitute.For <IDublicates>();
            var csvFileGenerator = new CsvFileGenerator(fileSystem, dublicates);
            var filename         = "customers";

            // Act
            csvFileGenerator.CreateCsvFile(filename, customers);

            // Assert
            fileSystem.Received(12).WriteLine(filename, Arg.Any <string>());
        }
Ejemplo n.º 2
0
        public void FileSystem_GivenAllData_ShouldSaveBatchesOf20Customers()
        {
            // Arrange
            var customers        = GetCustomCustomerList();
            var fileSystem       = Substitute.For <IFileSystem>();
            var dublicates       = new Duplicates();
            var csvFileGenerator = new CsvFileGenerator(fileSystem, dublicates);
            var filename         = "customers";

            // Act
            csvFileGenerator.GetBatchOfCustomers("customers", customers, 20);

            // Assert
            fileSystem.Received(20).WriteLine($"{filename}1.csv", Arg.Any <string>());
            fileSystem.Received(12).WriteLine($"{filename}2.csv", Arg.Any <string>());
        }
Ejemplo n.º 3
0
        public void CreateCSVFile_GivenCustomerBatchOf10Or1500_ShouldSave2Files(int numberOfCustomers, int maximumLineLimit, int access)
        {
            // Arrange
            var customers = Builder <Customer> .CreateListOfSize(numberOfCustomers).Build().ToList();

            var filename         = "customers";
            var fileSystem       = Substitute.For <IFileSystem>();
            var dublicates       = new Duplicates();
            var csvFileGenerator = new CsvFileGenerator(fileSystem, dublicates);

            // Act
            csvFileGenerator.GetBatchOfCustomers("customers", customers, maximumLineLimit);

            // Assert
            fileSystem.Received(maximumLineLimit).WriteLine($"{filename}1.csv", Arg.Any <string>());
            fileSystem.Received(access).WriteLine($"{filename}2.csv", Arg.Any <string>());
        }