Example #1
0
        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);
        }
Example #2
0
 public async Task GetZoneNotesPaginatedAsync_InvalidTemplateID_ThrowsANSClientValidationException()
 {
     var ops = new ZoneNoteOperations <Note>(null);
     await Assert.ThrowsExceptionAsync <ANSClientValidationException>(() => ops.GetNotesPaginatedAsync(""));
 }