public void ProcessAllRecords_WhenGivenGarbage_ThrowsBadFileFormatException() { var provider = new FakePaymentRecordProvider("this is not a valid file"); var reader = new BetaPaymentReader(provider, DateTime.Now); reader.ProcessAllRecords(); }
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; } }