예제 #1
0
        public void ProcessAllRecords_WhenGivenGarbage_ThrowsBadFileFormatException()
        {
            var provider = new FakePaymentRecordProvider("this is not a valid file");
            var reader = new BetaPaymentReader(provider, DateTime.Now);

            reader.ProcessAllRecords();
        }
예제 #2
0
        public void ProcessAllRecords_WhenGivenExampleFile_CreatesAValidBundle()
        {
            using (var provider = new FileRawPaymentRecordProvider(@"Examplefiles\example_betapayment.txt"))
            {
                var reader = new BetaPaymentReader(provider, DateTime.Now);

                var result = reader.ProcessAllRecords();

                Assert.AreEqual(1, result.Count, "nr of payment bundles");
                Assert.AreEqual(3, result.First().Payments.Count, "nr of payments");
            }
        }
예제 #3
0
        private IPaymentReader GetReader(FileRawPaymentRecordProvider provider)
        {
            IPaymentReader reader;
            var filename = provider.PaymentFilePath;
            if (filename.EndsWith("_alphapayment.txt"))
            {
                reader = new AlphaPaymentReader(provider);
            }
            else if (filename.EndsWith("_betapayment.txt"))
            {
                reader = new BetaPaymentReader(provider, DateTime.Today);
            }
            else
            {
                throw new ApplicationException($"Unable to determine type for payment file: {filename}");
            }

            return reader;
        }
예제 #4
0
        public void ProcessAllRecords_WhenFooterQuantityDoesNotMatchPaymentCount_ThrowsInnerInconsistentFileContentsException()
        {
            var provider = new FakePaymentRecordProvider(
"00000000005467233465356300000000000000000000000000000000000000000000000000000000",
"30000000000000003000000000000000000000005687543710               ",
"30000000000000001000000000000000000000005687543710               ",
"30000000000000010300000000000000000000005687543710               ",
"99000000000000014300000000000000000002000000000000000000000000000000000000000000");
            var reader = new BetaPaymentReader(provider, DateTime.Now);

            try
            {
                reader.ProcessAllRecords();
            }
            catch (Exception ex) 
            {
                // Ugly workaround since asserting on exceptions is quite severely limited in MsTest :(
                // The exception we're looking for is wrapped in a BadFileFormatException. 
                // Find the inner exception and throw it so that the ExpectedExceptionAttribute can find it
                if (ex.InnerException != null)
                    throw ex.InnerException;
            }
        }