public async Task EmptyStringPassedOk(string inputData) { var strategy = new XmlParsingStrategy(); var results = await strategy.ParseTransactionsAsync(new MemoryStream(Encoding.UTF8.GetBytes(inputData))) as XmlParsingResult; Assert.False(results.Success); Assert.Equal("There is an error in XML document (0, 0).", results.Error); }
public async Task InvalidStatusError(string inputData) { var strategy = new XmlParsingStrategy(); var results = await strategy.ParseTransactionsAsync(new MemoryStream(Encoding.UTF8.GetBytes(inputData))) as XmlParsingResult; Assert.False(results.Success); Assert.Equal($"Object 1 validation errors: Invalid status: SomeStatus", results.Error); }
public async Task IdLengthFor50PassesOk(string inputData) { var strategy = new XmlParsingStrategy(); var results = await strategy.ParseTransactionsAsync(new MemoryStream(Encoding.UTF8.GetBytes(inputData))) as XmlParsingResult; Assert.True(results.Success); Assert.Single(results.XmlTransactions); _outputHelper.WriteLine(string.Join(Environment.NewLine, results.XmlTransactions.Select(t => t.ToString()))); }
public async Task InvalidCurrencyError(string inputData) { var strategy = new XmlParsingStrategy(); var results = await strategy.ParseTransactionsAsync(new MemoryStream(Encoding.UTF8.GetBytes(inputData))) as XmlParsingResult; Assert.False(results.Success); Assert.Equal($"Object 1 validation errors: Invalid currency code ZZZ", results.Error); _outputHelper.WriteLine(string.Join(Environment.NewLine, results.XmlTransactions.Select(t => t.ToString()))); }
public async Task IdLengthFor51Fails(string inputData) { var strategy = new XmlParsingStrategy(); var results = await strategy.ParseTransactionsAsync(new MemoryStream(Encoding.UTF8.GetBytes(inputData))) as XmlParsingResult; Assert.False(results.Success); Assert.Equal($"Object 1 validation errors: Id attributes is over 50 characters long: Invoice0000001Invoice0000001Invoice0000001Invoice01\r\nObject 3 validation errors: Id attributes is over 50 characters long: Invoice0000001Invoice0000001Invoice0000001Invoice01", results.Error); _outputHelper.WriteLine(string.Join(Environment.NewLine, results.XmlTransactions.Select(t => t.ToString()))); }
public async Task FieldDetailsReadOk(string inputData) { var strategy = new XmlParsingStrategy(); var results = await strategy.ParseTransactionsAsync(new MemoryStream(Encoding.UTF8.GetBytes(inputData))) as XmlParsingResult; Assert.True(results.Success); Assert.Single(results.XmlTransactions); Assert.Equal("Inv00001", results.XmlTransactions[0].Id); Assert.Equal(200.00M, results.XmlTransactions[0].Amount); Assert.Equal("USD", results.XmlTransactions[0].PaymentDetails.CurrencyCode); Assert.Equal(new DateTime(2019, 01, 23, 13, 45, 10), results.XmlTransactions[0].TransactionDateLocal); Assert.Equal(XmlStatus.Done, results.XmlTransactions[0].XmlStatus); _outputHelper.WriteLine(string.Join(Environment.NewLine, results.XmlTransactions.Select(t => t.ToString()))); }