public void ReinstateMandateRequestIsNullThrows() { // given var subject = new MandatesClient(_clientConfiguration); ReinstateMandateRequest request = null; // when AsyncTestDelegate test = () => subject.ReinstateAsync(request); // then var ex = Assert.ThrowsAsync <ArgumentNullException>(test); Assert.That(ex.ParamName, Is.EqualTo(nameof(request))); }
public async Task CallsReinstateMandateEndpoint() { // given var subject = new MandatesClient(_clientConfiguration); var request = new ReinstateMandateRequest { Id = "MD12345678" }; // when await subject.ReinstateAsync(request); // then _httpTest .ShouldHaveCalled("https://api.gocardless.com/mandates/MD12345678/actions/reinstate") .WithVerb(HttpMethod.Post); }
public void ReinstateMandateRequestIdIsNullOrWhiteSpaceThrows(string id) { // given var subject = new MandatesClient(_clientConfiguration); var request = new ReinstateMandateRequest { Id = id }; // when AsyncTestDelegate test = () => subject.ReinstateAsync(request); // then var ex = Assert.ThrowsAsync <ArgumentException>(test); Assert.That(ex.ParamName, Is.EqualTo(nameof(request.Id))); }
public async Task CreatesCancelsAndReinstatesMandate() { // given var createRequest = new CreateMandateRequest { Links = new CreateMandateLinks { Creditor = _creditor.Id, CustomerBankAccount = _customerBankAccount.Id }, Metadata = new Dictionary <string, string> { ["Key1"] = "Value1", ["Key2"] = "Value2", ["Key3"] = "Value3", }, Reference = DateTime.Now.ToString("yyyyMMddhhmmss"), Scheme = Scheme.Bacs }; var subject = new MandatesClient(_clientConfiguration); // when var creationResult = await subject.CreateAsync(createRequest); var cancelRequest = new CancelMandateRequest { Id = creationResult.Item.Id, Metadata = new Dictionary <string, string> { ["Key4"] = "Value4", ["Key5"] = "Value5", ["Key6"] = "Value6", }, }; var cancellationResult = await subject.CancelAsync(cancelRequest); var reinstateRequest = new ReinstateMandateRequest { Id = creationResult.Item.Id, Metadata = new Dictionary <string, string> { ["Key7"] = "Value7", ["Key8"] = "Value8", ["Key9"] = "Value9", }, }; var reinstateResult = (await subject.ReinstateAsync(reinstateRequest)); // then Assert.That(creationResult.Item, Is.Not.Null); Assert.That(creationResult.Item.Id, Is.Not.Null); Assert.That(creationResult.Item.CreatedAt, Is.Not.EqualTo(default(DateTimeOffset))); Assert.That(creationResult.Item.Links.Creditor, Is.EqualTo(_creditor.Id)); Assert.That(creationResult.Item.Links.CustomerBankAccount, Is.EqualTo(_customerBankAccount.Id)); Assert.That(creationResult.Item.Metadata, Is.EqualTo(createRequest.Metadata)); Assert.That(creationResult.Item.NextPossibleChargeDate, Is.Not.Null.And.Not.EqualTo(default(DateTime))); Assert.That(creationResult.Item.Reference, Is.Not.Null.And.EqualTo(createRequest.Reference)); Assert.That(creationResult.Item.Scheme, Is.EqualTo(createRequest.Scheme)); Assert.That(creationResult.Item.Status, Is.Not.Null.And.Not.EqualTo(MandateStatus.Cancelled)); Assert.That(cancellationResult.Item.Status, Is.EqualTo(MandateStatus.Cancelled)); Assert.That(reinstateResult.Item.Status, Is.Not.Null.And.Not.EqualTo(MandateStatus.Cancelled)); }