public async Task UpdatesRefundReplacingMetadata() { // given var subject = new RefundsClient(_clientConfiguration); var refund = (await subject.GetPageAsync()).Items.First(); var now = DateTime.Now.ToString("yyyyMMdd"); var request = new UpdateRefundRequest { Id = refund.Id, Metadata = new Dictionary <string, string> { [$"Key-1-{now}"] = $"Value-1-{now}", [$"Key-2-{now}"] = $"Value-2-{now}", [$"Key-3-{now}"] = $"Value-3-{now}", }, }; // 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.And.EqualTo(refund.Id)); Assert.That(actual.Amount, Is.Not.Null.And.EqualTo(refund.Amount)); Assert.That(actual.Currency, Is.Not.Null.And.EqualTo(refund.Currency)); Assert.That(actual.CreatedAt, Is.Not.Null.And.EqualTo(refund.CreatedAt)); Assert.That(actual.Links, Is.Not.Null); Assert.That(actual.Links.Mandate, Is.Not.Null.And.EqualTo(refund.Links.Mandate)); Assert.That(actual.Links.Payment, Is.Not.Null.And.EqualTo(refund.Links.Payment)); Assert.That(actual.Metadata, Is.Not.Null.And.EqualTo(request.Metadata)); Assert.That(actual.Reference, Is.Not.Null.And.EqualTo(refund.Reference)); }
public async Task UpdatesRefundPreservingMetadata() { // given var subject = new RefundsClient(_clientConfiguration); var refund = (await subject.GetPageAsync()).Items.First(); var request = new UpdateRefundRequest { Id = refund.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.And.EqualTo(refund.Id)); Assert.That(actual.Amount, Is.Not.Null.And.EqualTo(refund.Amount)); Assert.That(actual.Currency, Is.Not.Null.And.EqualTo(refund.Currency)); Assert.That(actual.CreatedAt, Is.Not.Null.And.EqualTo(refund.CreatedAt)); Assert.That(actual.Links, Is.Not.Null); Assert.That(actual.Links.Mandate, Is.Not.Null.And.EqualTo(refund.Links.Mandate)); Assert.That(actual.Links.Payment, Is.Not.Null.And.EqualTo(refund.Links.Payment)); Assert.That(actual.Metadata, Is.Not.Null.And.EqualTo(refund.Metadata)); Assert.That(actual.Reference, Is.Not.Null.And.EqualTo(refund.Reference)); }
public void UpdateRefundRequestIsNullThrows() { // given var subject = new RefundsClient(_clientConfiguration); UpdateRefundRequest request = null; // when AsyncTestDelegate test = () => subject.UpdateAsync(request); // then var ex = Assert.ThrowsAsync <ArgumentNullException>(test); Assert.That(ex.ParamName, Is.EqualTo(nameof(request))); }
public async Task CallsUpdateRefundEndpoint() { // given var subject = new RefundsClient(_clientConfiguration); var request = new UpdateRefundRequest { Id = "RF12345678" }; // when await subject.UpdateAsync(request); // then _httpTest .ShouldHaveCalled("https://api.gocardless.com/refunds") .WithVerb(HttpMethod.Put); }
public void UpdateRefundRequestIdIsNullOrWhiteSpaceThrows(string id) { // given var subject = new RefundsClient(_clientConfiguration); var request = new UpdateRefundRequest { Id = id }; // when AsyncTestDelegate test = () => subject.UpdateAsync(request); // then var ex = Assert.ThrowsAsync <ArgumentException>(test); Assert.That(ex.ParamName, Is.EqualTo(nameof(request.Id))); }