public async Task DeleteDomainAsync_ValidParameters_ExpectedClientCall() { var ops = new DomainOperations <Domain>(_client); await ops.DeleteDomainAsync("test-domain.co.uk"); await _client.Received().DeleteAsync("/ddosx/v1/domains/test-domain.co.uk"); }
public async Task CreateDomainAsync_ExpectedResult() { var req = new CreateDomainRequest() { Name = "test-domain.co.uk" }; var ops = new DomainOperations <Domain>(_client); await ops.CreateDomainAsync(req); await _client.Received().PostAsync("/ddosx/v1/domains", req); }
public async Task GetDomainAsync_ValidParameters_ExpectedResult() { _client.GetAsync <Domain>($"/ddosx/v1/domains/test-domain.co.uk").Returns(new Domain() { Name = "test-domain.co.uk" }); var ops = new DomainOperations <Domain>(_client); var domain = await ops.GetDomainAsync("test-domain.co.uk"); Assert.AreEqual("test-domain.co.uk", domain.Name); }
public async Task GetDomainAsync_ValidParameters_ExpectedResult() { IUKFastRegistrarClient client = Substitute.For <IUKFastRegistrarClient>(); client.GetAsync <Domain>("/registrar/v1/domains/ukfast.co.uk").Returns(new Domain() { Name = "ukfast.co.uk" }); var ops = new DomainOperations <Domain>(client); var domain = await ops.GetDomainAsync("ukfast.co.uk"); Assert.AreEqual("ukfast.co.uk", domain.Name); }
public async Task GetDomainsAsync_ExpectedResult() { _client.GetAllAsync(Arg.Any <UKFastClient.GetPaginatedAsyncFunc <Domain> >(), null).Returns( Task.Run <IList <Domain> >(() => new List <Domain>() { new Domain(), new Domain() })); var ops = new DomainOperations <Domain>(_client); var domains = await ops.GetDomainsAsync(); Assert.AreEqual(2, domains.Count); }
public bool Load(string nodesXMLFilename) { try { XElement x = XElement.Load(nodesXMLFilename, LoadOptions.None); XElement settings = x.Element("settings"); foreach (XElement n in x.Elements("node")) { switch (n.Attribute("type").Value) { case "do": DistancePrimitive dp = new DistancePrimitive(n.Attribute("name").Value, n.Attribute("caption").Value, n.Attribute("code").Value); foreach (XElement p in n.Elements("prop")) { dp.Properties.Add(createInputProperty(p.Attribute("type").Value, p.Attribute("name").Value, p.Attribute("default").Value)); } DistanceFieldTypes.Add(dp); break; case "distop": DistanceOperation distop = new DistanceOperation(n.Attribute("name").Value, n.Attribute("caption").Value, n.Attribute("code").Value); foreach (XElement p in n.Elements("prop")) { distop.Properties.Add(createInputProperty(p.Attribute("type").Value, p.Attribute("name").Value, p.Attribute("default").Value)); } DistanceOperations.Add(distop); break; case "domop": DomainOperation dop = new DomainOperation(n.Attribute("name").Value, n.Attribute("caption").Value, n.Attribute("code").Value); foreach (XElement p in n.Elements("prop")) { dop.Properties.Add(createInputProperty(p.Attribute("type").Value, p.Attribute("name").Value, p.Attribute("default").Value)); } DomainOperations.Add(dop); break; } } } catch (Exception e) { errors.Add("Failed to load nodes.xml (" + e.Message + ")"); return(false); } return(true); }
public async Task GetDomainsAsync_ExpectedResult() { IUKFastRegistrarClient client = Substitute.For <IUKFastRegistrarClient>(); client.GetAllAsync(Arg.Any <UKFastClient.GetPaginatedAsyncFunc <Domain> >(), null).Returns(Task.Run <IList <Domain> >(() => { return(new List <Domain>() { new Domain(), new Domain() }); })); var ops = new DomainOperations <Domain>(client); var domains = await ops.GetDomainsAsync(); Assert.AreEqual(2, domains.Count); }
public async Task GetDomainsPaginatedAsync_ExpectedResult() { _client.GetPaginatedAsync <Domain>("/ddosx/v1/domains").Returns( Task.Run(() => new Paginated <Domain>(_client, "/ddosx/v1/domains", null, new ClientResponse <IList <Domain> >() { Body = new ClientResponseBody <IList <Domain> >() { Data = new List <Domain>() { new Domain(), new Domain() } } }))); var ops = new DomainOperations <Domain>(_client); var paginated = await ops.GetDomainsPaginatedAsync(); Assert.AreEqual(2, paginated.Items.Count); }
public async Task GetDomainsPaginatedAsync_ExpectedClientCall() { IUKFastRegistrarClient client = Substitute.For <IUKFastRegistrarClient>(); client.GetPaginatedAsync <Domain>("/registrar/v1/domains").Returns(Task.Run(() => { return(new Paginated <Domain>(client, "/registrar/v1/domains", null, new Response.ClientResponse <System.Collections.Generic.IList <Domain> >() { Body = new Response.ClientResponseBody <System.Collections.Generic.IList <Domain> >() { Data = new List <Domain>() { new Domain(), new Domain() } } })); })); var ops = new DomainOperations <Domain>(client); var paginated = await ops.GetDomainsPaginatedAsync(); Assert.AreEqual(2, paginated.Items.Count); }
public bool Setup(string functionsXMLFilename) { try { XElement x = XElement.Load(functionsXMLFilename, LoadOptions.None); XElement helpers = x.Element("helpers"); foreach (XElement h in helpers.Elements("code")) { XAttribute comment = h.Attribute("comment"); HelperCode helper = new HelperCode(h.Attribute("name").Value, h.Value, comment == null ? "" : comment.Value); Helpers.Add(helper.Name, helper); } XElement nodes = x.Element("nodes"); foreach (XElement n in nodes.Elements("node")) { string code = ""; string[] requires = null; XElement func = n.Element("function"); if (func != null) { code = func.Value; XAttribute requ = func.Attribute("requires"); if (requ != null) { requires = requ.Value.Split(",".ToCharArray()); } } XAttribute com = n.Attribute("comment"); string comment = ""; if (com != null) { comment = com.Value; } SceneNode node = null; switch (n.Attribute("type").Value) { case "dp": node = new DistancePrimitive(n.Attribute("name").Value, n.Attribute("caption").Value, n.Attribute("mask").Value, code, requires, comment); DistanceFieldTypes.Add(node as DistancePrimitive); break; case "distop": node = new DistanceOperation(n.Attribute("name").Value, n.Attribute("caption").Value, n.Attribute("mask").Value, code, requires, comment); DistanceOperations.Add(node as DistanceOperation); break; case "domop": node = new DomainOperation(n.Attribute("name").Value, n.Attribute("caption").Value, n.Attribute("mask").Value, code, requires, comment); DomainOperations.Add(node as DomainOperation); break; } if (node != null && n.Element("properties") != null) { foreach (XElement p in n.Element("properties").Elements("property")) { node.Properties.Add(createInputProperty(p.Attribute("type").Value, p.Attribute("name").Value, p.Attribute("default").Value)); } } } } catch (Exception e) { errors.Add("Failed to load/parse " + functionsXMLFilename + ":\n" + e.Message); return(false); } return(true); }
public async Task GetDomainAsync_InvalidDomainName_ThrowsUKFastClientValidationException() { var ops = new DomainOperations <Domain>(null); await Assert.ThrowsExceptionAsync <UKFastClientValidationException>(() => ops.GetDomainAsync("")); }