public async Task GetZoneNoteAsync_ValidParameters_ExpectedResult() { IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); client.GetAsync <Note>("/safedns/v1/zones/example.com/notes/123").Returns(new Note() { ID = 123 }); var ops = new ZoneNoteOperations <Note>(client); var note = await ops.GetNoteAsync("example.com", 123); Assert.AreEqual(123, note.ID); }
public async Task GetZoneNotesAsync_ExpectedResult() { IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); var ops = new ZoneNoteOperations <Note>(client); client.GetAllAsync(Arg.Any <ANSClient.GetPaginatedAsyncFunc <Note> >(), null).Returns(Task.Run <IList <Note> >(() => { return(new List <Note>() { new Note(), new Note() }); })); var notes = await ops.GetNotesAsync("example.com"); Assert.AreEqual(2, notes.Count); }
public async Task CreateZoneNoteAsync_ExpectedResult() { CreateNoteRequest req = new CreateNoteRequest() { Notes = "test note" }; IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); client.PostAsync <Note>("/safedns/v1/zones/example.com/notes", req).Returns(new Note() { ID = 123 }); var ops = new ZoneNoteOperations <Note>(client); int id = await ops.CreateNoteAsync("example.com", req); Assert.AreEqual(123, id); }
public async Task GetZoneNotesPaginatedAsync_ExpectedClientCall() { IANSSafeDNSClient client = Substitute.For <IANSSafeDNSClient>(); client.GetPaginatedAsync <Note>("/safedns/v1/zones/example.com/notes").Returns(Task.Run(() => { return(new Paginated <Note>(client, "/safedns/v1/zones/example.com/notes", null, new Response.ClientResponse <System.Collections.Generic.IList <Note> >() { Body = new Response.ClientResponseBody <System.Collections.Generic.IList <Note> >() { Data = new List <Note>() { new Note(), new Note() } } })); })); var ops = new ZoneNoteOperations <Note>(client); var paginated = await ops.GetNotesPaginatedAsync("example.com"); Assert.AreEqual(2, paginated.Items.Count); }
public async Task GetZoneNotesPaginatedAsync_InvalidTemplateID_ThrowsANSClientValidationException() { var ops = new ZoneNoteOperations <Note>(null); await Assert.ThrowsExceptionAsync <ANSClientValidationException>(() => ops.GetNotesPaginatedAsync("")); }
public async Task CreateZoneNoteAsync_InvalidTemplateID_ThrowsANSClientValidationException() { var ops = new ZoneNoteOperations <Note>(null); await Assert.ThrowsExceptionAsync <ANSClientValidationException>(() => ops.CreateNoteAsync("", null)); }
public async Task GetZoneNoteAsync_InvalidNoteID_ThrowsANSClientValidationException() { var ops = new ZoneNoteOperations <Note>(null); await Assert.ThrowsExceptionAsync <ANSClientValidationException>(() => ops.GetNoteAsync("example.com", 0)); }
public async Task GetZoneNoteAsync_InvalidZoneName_ThrowsANSClientValidationException() { var ops = new ZoneNoteOperations <Note>(null); await Assert.ThrowsExceptionAsync <ANSClientValidationException>(() => ops.GetNoteAsync("", 123)); }