public async Task CreateFileData_Always_CreatesFileData()
        {
            // Arrange
            CustomerFile customerFile = new CustomerFile("WEE", (ulong)12345);
            var          customerFileGeneratorResult         = new IbisFileGeneratorResult <CustomerFile>(customerFile, A.Dummy <List <Exception> >());
            IIbisCustomerFileGenerator customerFileGenerator = A.Fake <IIbisCustomerFileGenerator>();

            A.CallTo(() => customerFileGenerator.CreateAsync(A <ulong> ._, A <InvoiceRun> ._))
            .Returns(customerFileGeneratorResult);

            TransactionFile transactionFile         = new TransactionFile("WEE", (ulong)12345);
            var             ibisFileGeneratorResult = new IbisFileGeneratorResult <TransactionFile>(transactionFile, A.Dummy <List <Exception> >());
            IIbisTransactionFileGenerator transactionFileGenerator = A.Fake <IIbisTransactionFileGenerator>();

            A.CallTo(() => transactionFileGenerator.CreateAsync(A <ulong> ._, A <InvoiceRun> ._))
            .Returns(ibisFileGeneratorResult);

            IIbisFileDataErrorTranslator errorTranslator = A.Dummy <IIbisFileDataErrorTranslator>();

            IbisFileDataGenerator generator = new IbisFileDataGenerator(
                customerFileGenerator,
                transactionFileGenerator,
                errorTranslator);

            // Act
            var result = await generator.CreateFileDataAsync(A.Dummy <ulong>(), A.Dummy <InvoiceRun>());

            var ibistFileData = result.IbisFileData;

            // Assert
            Assert.NotNull(ibistFileData);
            Assert.False(string.IsNullOrEmpty(ibistFileData.CustomerFileData));
            Assert.False(string.IsNullOrEmpty(ibistFileData.TransactionFileData));
        }
 public IbisFileDataGenerator(
     IIbisCustomerFileGenerator ibisCustomerFileGenerator,
     IIbisTransactionFileGenerator ibisTransactionFileGenerator,
     IIbisFileDataErrorTranslator ibisFileDataErrorTranslator)
 {
     this.ibisCustomerFileGenerator = ibisCustomerFileGenerator;
     this.ibisTransactionFileGenerator = ibisTransactionFileGenerator;
     this.ibisFileDataErrorTranslator = ibisFileDataErrorTranslator;
 }
Example #3
0
 public IbisFileDataGenerator(
     IIbisCustomerFileGenerator ibisCustomerFileGenerator,
     IIbisTransactionFileGenerator ibisTransactionFileGenerator,
     IIbisFileDataErrorTranslator ibisFileDataErrorTranslator)
 {
     this.ibisCustomerFileGenerator    = ibisCustomerFileGenerator;
     this.ibisTransactionFileGenerator = ibisTransactionFileGenerator;
     this.ibisFileDataErrorTranslator  = ibisFileDataErrorTranslator;
 }
        public async Task CreateFileData_WithFileID_CreatesFilesWithCorrectFileNames()
        {
            // Arrange
            ulong fileID = 123;

            CustomerFile customerFile = new CustomerFile("WEE", (ulong)12345);
            var          customerFileGeneratorResult         = new IbisFileGeneratorResult <CustomerFile>(customerFile, A.Dummy <List <Exception> >());
            IIbisCustomerFileGenerator customerFileGenerator = A.Fake <IIbisCustomerFileGenerator>();

            A.CallTo(() => customerFileGenerator.CreateAsync(A <ulong> ._, A <InvoiceRun> ._))
            .Returns(customerFileGeneratorResult);

            TransactionFile transactionFile         = new TransactionFile("WEE", (ulong)12345);
            var             ibisFileGeneratorResult = new IbisFileGeneratorResult <TransactionFile>(transactionFile, A.Dummy <List <Exception> >());
            IIbisTransactionFileGenerator transactionFileGenerator = A.Fake <IIbisTransactionFileGenerator>();

            A.CallTo(() => transactionFileGenerator.CreateAsync(A <ulong> ._, A <InvoiceRun> ._))
            .Returns(ibisFileGeneratorResult);

            IIbisFileDataErrorTranslator errorTranslator = A.Dummy <IIbisFileDataErrorTranslator>();

            IbisFileDataGenerator generator = new IbisFileDataGenerator(
                customerFileGenerator,
                transactionFileGenerator,
                errorTranslator);

            // Act
            var result = await generator.CreateFileDataAsync(fileID, A.Dummy <InvoiceRun>());

            var ibistFileData = result.IbisFileData;

            // Assert
            Assert.NotNull(ibistFileData);
            Assert.Equal("WEEHC00123.dat", ibistFileData.CustomerFileName);
            Assert.Equal("WEEHI00123.dat", ibistFileData.TransactionFileName);
        }