Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        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())));
        }
Example #4
0
        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())));
        }
Example #5
0
        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())));
        }
Example #6
0
        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())));
        }