public async Task HandlesCustomerNotification()
        {
            // given
            var creditor = await _resourceFactory.Creditor();

            var customer = await _resourceFactory.CreateLocalCustomer();

            var customerBankAccount = await _resourceFactory.CreateCustomerBankAccountFor(customer);

            await _resourceFactory.CreateMandateFor(creditor, customer, customerBankAccount);

            var subject = new CustomerNotificationsClient(_clientConfiguration);

            var id = "PCN0000DZ5X5BG0";

            // when
            var result = await subject.HandleAsync(id);

            // then
            Assert.That(result.Item, Is.Not.Null);
            Assert.That(result.Item.Id, Is.Not.Null.And.EqualTo(id));
            Assert.That(result.Item.ActionTaken, Is.Not.Null.And.EqualTo(ActionTaken.Handled));
            Assert.That(result.Item.ActionTakenAt, Is.Not.Null.And.Not.EqualTo(default(DateTimeOffset)));
            Assert.That(result.Item.ActionTakenBy, Is.Not.Null);
            Assert.That(result.Item.Links, Is.Not.Null);
            Assert.That(result.Item.Links.Customer, Is.Not.Null);
            Assert.That(result.Item.Links.Event, Is.Not.Null);
            Assert.That(result.Item.Links.Mandate, Is.Not.Null);
            Assert.That(result.Item.Type, Is.Not.Null);
        }
        public void IdIsNullOrWhiteSpaceThrows(string id)
        {
            // given
            var subject = new CustomerNotificationsClient(_clientConfiguration);

            // when
            AsyncTestDelegate test = () => subject.HandleAsync(id);

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

            Assert.That(ex.ParamName, Is.EqualTo(nameof(id)));
        }
        public async Task CallsHandleCustomerNotificationsEndpoint()
        {
            // given
            var subject = new CustomerNotificationsClient(_clientConfiguration);
            var id      = "PCN12345678";

            // when
            await subject.HandleAsync(id);

            // then
            _httpTest
            .ShouldHaveCalled("https://api.gocardless.com/customer_notifications")
            .WithVerb(HttpMethod.Post);
        }