public async Task UpdatesCustomerBankAccountReplacingMetadata()
        {
            // given
            var customer = await _resourceFactory.CreateLocalCustomer();

            var customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            var request = new UpdateCustomerBankAccountRequest
            {
                Id       = customerBankAccount.Id,
                Metadata = new Dictionary <string, string>
                {
                    ["Key4"] = "Value4",
                    ["Key5"] = "Value5",
                    ["Key6"] = "Value6",
                },
            };

            // when
            var result = await subject.UpdateAsync(request);

            var actual = result.Item;

            // then
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.Not.Null);
            Assert.That(actual.Metadata, Is.EqualTo(request.Metadata));
        }
Exemple #2
0
        public void UpdateCustomerBankAccountRequestIsNullThrows()
        {
            // given
            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            UpdateCustomerBankAccountRequest request = null;

            // when
            AsyncTestDelegate test = () => subject.UpdateAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentNullException>(test);

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request)));
        }
Exemple #3
0
        public async Task CallsUpdateCustomerBankAccountEndpoint()
        {
            // given
            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            var request = new UpdateCustomerBankAccountRequest
            {
                Id = "BA12345678"
            };

            // when
            await subject.UpdateAsync(request);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/customer_bank_accounts")
            .WithVerb(HttpMethod.Put);
        }
Exemple #4
0
        public void UpdateCustomerBankAccountRequestIdIsNullEmptyOrWhiteSpaceThrows(string id)
        {
            // given
            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            var request = new UpdateCustomerBankAccountRequest
            {
                Id = id
            };

            // when
            AsyncTestDelegate test = () => subject.UpdateAsync(request);

            // then
            var ex = Assert.ThrowsAsync <ArgumentException>(test);

            Assert.That(ex.ParamName, Is.EqualTo(nameof(request.Id)));
        }
        public async Task UpdatesCustomerBankAccountPreservingMetadata()
        {
            // given
            var customer = await _resourceFactory.CreateLocalCustomer();

            var customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            var subject = new CustomerBankAccountsClient(_clientConfiguration);

            var request = new UpdateCustomerBankAccountRequest
            {
                Id = customerBankAccount.Id
            };

            // when
            var result = await subject.UpdateAsync(request);

            var actual = result.Item;

            // then
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Id, Is.Not.Null);
            Assert.That(actual.Metadata, Is.EqualTo(customerBankAccount.Metadata));
        }