public void GivenAnImporter_WhenImportingFromEmptyStream_ThenNoCustomerIsImported()
        {
            var streamReader     = new StreamStubBuilder().Build();
            var dataBase         = new MemoryDataBase();
            var customerImporter = new CustomerImporter(dataBase, streamReader);

            customerImporter.Import();

            var customers = dataBase.GetCustomers();

            Assert.Empty(customers);
        }
        public void GivenAnImporter_WhenImportingStreamWithCustomerWithInvalidAmountOfFields_ThenAnExceptionIsThrown(string invalidRecord)
        {
            var streamReader = new StreamStubBuilder()
                               .AddLine(invalidRecord)
                               .Build();

            var dataBase         = new MemoryDataBase();
            var customerImporter = new CustomerImporter(dataBase, streamReader);

            var exception = Assert.Throws <ArgumentException>(() => customerImporter.Import());

            Assert.Equal(CustomerImporter.FIELD_AMOUNT_IS_INVALID_EXCEPTION, exception.Message);
        }
        public void GivenAnImporter_WhenImportingUnrecognizedRecord_ThenAnExceptionIsThrown(string unrecognizedRecord)
        {
            var streamReader = new StreamStubBuilder()
                               .AddLine(unrecognizedRecord)
                               .Build();

            var dataBase         = new MemoryDataBase();
            var customerImporter = new CustomerImporter(dataBase, streamReader);

            var exception = Assert.Throws <ArgumentException>(() => customerImporter.Import());

            Assert.Equal(CustomerImporter.RECORD_IS_UNRECOGNIZED_EXCEPTION, exception.Message);
        }
        public void GivenAnImporter_WhenImportingStreamWithIncompleteAddress_ThenAnExceptionIsThrown()
        {
            var streamReader = new StreamStubBuilder()
                               .AddLine("C,Juan,Perez,C,23-25666777-9")
                               .AddLine("A,Alem,1122,CABA,1001")
                               .Build();

            var dataBase         = new MemoryDataBase();
            var customerImporter = new CustomerImporter(dataBase, streamReader);

            var exception = Assert.Throws <ArgumentException>(() => customerImporter.Import());

            Assert.Equal(CustomerImporter.FIELD_AMOUNT_IS_INVALID_EXCEPTION, exception.Message);
        }