public void AndInvalidDecimalSeparator_ThenReturnPayment_WithParsingErrors()
        {
            var sut            = new PaymentParserJsonGB();
            var expectedAmount = "100,21";

            var testJson = $@"{{
                'data': [{{
                    'attributes':{{
                        'amount': '{expectedAmount}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(true);
        }
        public void AndDateInDiffernetFormat_ThenReturnPayment_AndParsingErrors()
        {
            var sut          = new PaymentParserJsonGB();
            var expectedDate = "2017-18-01";

            var testJson = $@"{{
                'data': [{{
                    'attributes': {{
                        'processing_date': '{expectedDate}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(true);
        }
        public void AndDateTimeWithMinutesAndHours_IsInValid_ThenReturnPayment_AndParsingErrors()
        {
            var sut          = new PaymentParserJsonGB();
            var expectedDate = "2017-01-18 10:10:10";

            var testJson = $@"{{
                'data': [{{
                    'attributes': {{
                        'processing_date': '{expectedDate}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(true);
        }
        public void TheFieldsAreCorrectlyParsed(string sourceField, string targetField)
        {
            var sut           = new PaymentParserJsonGB();
            var expectedValue = $"test - data {targetField}";

            var testJson = $@"{{
                'data': [{{
                    'attributes': {{
                        '{sourceField}': '{expectedValue}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(false);
            expectedValue.Should().Be(TestHelper.GetStringValueUsingFieldName(targetField, resultPayment.First().Attributes));
        }
        public void AndNegativeValue_ThenReturnPayment_WithParsingErrors()
        {
            var sut            = new PaymentParserJsonGB();
            var expectedAmount = "-100.21";

            var testJson = $@"{{
                'data': [{{
                    'attributes':{{
                        'amount': '{expectedAmount}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(false);
            expectedAmount.Should().Be(resultPayment.First().Attributes.Amount.ToString());
        }
        public void AndAmountIsValid_ThenReturnPayment_AndNoParsingErrors()
        {
            var sut            = new PaymentParserJsonGB();
            var expectedAmount = 100.21m;

            var testJson = $@"{{
                'data': [{{
                    'attributes': {{
                        'amount': '{expectedAmount}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            expectedAmount.Should().Be(resultPayment.First().Attributes.Amount);
            sut.HasErrors.Should().Be(false);
        }
        public void AndDateTimeFormatIsValid_ThenReturnPayment_AndNoParsingErrors()
        {
            var sut            = new PaymentParserJsonGB();
            var expectedDate   = "2017-01-18";
            var expectedFormat = "yyyy-MM-dd";

            var testJson = $@"{{
                'data': [{{
                    'attributes': {{
                        'processing_date': '{expectedDate}'
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(false);
            expectedDate.Should().Be(resultPayment.First().Attributes.ProcessingDate.ToString(expectedFormat));
        }
        public void ForParty_TheFieldsAreCorrectlyMapped(string partyType)
        {
            var sut                   = new PaymentParserJsonGB();
            var testAccountName       = "accountName";
            var testAccountNumber     = "accountNumber";
            var testAccountNumberCode = "accountNumberCode";
            var testAccountType       = 9;
            var testAddress           = "address";
            var testBankId            = "bankId";
            var testBankIdCode        = "bankCode";
            var testName              = "name";

            var testJson = $@"{{
                'data': [{{
                    'attributes': {{
                        '{partyType}_party': {{
                            'account_name': '{testAccountName}',
                            'account_number': '{testAccountNumber}',
                            'account_number_code': '{testAccountNumberCode}',
                            'account_type': '{testAccountType}',
                            'address': '{testAddress}',
                            'bank_id': '{testBankId}',
                            'bank_id_code': '{testBankIdCode}',
                            'name': '{testName}'
                        }}
                    }}
                }}]
            }}";

            var resultPayment = sut.Parse(testJson);

            sut.HasErrors.Should().Be(false);

            var attributes = resultPayment.First().Attributes;

            Party testParty = null;

            // this is not perfect but adding refleciton here would be an overkill
            // This test is maybe overcomplicated and should be split
            switch (partyType)
            {
            case "beneficiary":
                testParty = attributes.Beneficiary;
                break;

            case "debtor":
                testParty = attributes.Debtor;
                break;

            case "sponsor":
                testParty = attributes.Sponsor;
                break;
            }

            testParty.AccountName.Should().Be(testAccountName);
            testParty.AccountNumber.Should().Be(testAccountNumber);
            testParty.AccountType.Should().Be(testAccountType);
            testParty.AccountNumberCode.Should().Be(testAccountNumberCode);
            testParty.Address.Should().Be(testAddress);
            testParty.BankId.Should().Be(testBankId);
            testParty.BankIdCode.Should().Be(testBankIdCode);
        }