public void CorrectRequestForCreate() { var factory = Substitute.For<IConnection>(); var client = new TagsClient(factory); client.Create("notarealtag"); factory.Received().ExecuteRequest<Tag>("tags", null, Arg.Is<Models.Requests.Tag>(data => data.Name == "notarealtag"), "tag", Method.POST); }
public void CorrectRequestForGetAll() { var factory = Substitute.For<IConnection>(); var client = new TagsClient(factory); client.GetAll(); factory.Received().GetPaginated<Tag>("tags", null, "tags"); }
public void CorrectRequestForUpdate() { var factory = Substitute.For<IConnection>(); var client = new TagsClient(factory); client.Update("notarealtag", "notarealtag2"); var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "notarealtag"); factory.Received().ExecuteRequest<Tag>("tags/{name}", parameters, Arg.Is<Models.Requests.Tag>(data => data.Name == "notarealtag2"), "tag", Method.PUT); }
public void CorrectRequestForDelete() { var factory = Substitute.For<IConnection>(); var client = new TagsClient(factory); client.Delete("notarealtag"); var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "notarealtag"); factory.Received().ExecuteRaw("tags/{name}", parameters, null, Method.DELETE); }
public void CorrectRequestForUntag() { var factory = Substitute.For<IConnection>(); var client = new TagsClient(factory); List<KeyValuePair<string, string>> resources = new List<KeyValuePair<string, string>>(new KeyValuePair<string, string>[] { new KeyValuePair<string, string>("9001", "droplet"), new KeyValuePair<string, string>("9002", "droplet") }); client.Untag("notarealtag", resources); var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "notarealtag"); factory.Received().ExecuteRaw("tags/{name}/resources", parameters, Arg.Is<Models.Requests.TagResource>(data => data.Resources[1].Id == "9002"), Method.DELETE); }
public DigitalOceanClient(string token) { var client = new RestClient(DigitalOceanApiUrl) { UserAgent = "digitalocean-api-dotnet" }; client.AddDefaultHeader("Authorization", string.Format("Bearer {0}", token)); _connection = new Connection(client); Actions = new ActionsClient(_connection); DomainRecords = new DomainRecordsClient(_connection); Domains = new DomainsClient(_connection); DropletActions = new DropletActionsClient(_connection); Droplets = new DropletsClient(_connection); ImageActions = new ImageActionsClient(_connection); Images = new ImagesClient(_connection); Keys = new KeysClient(_connection); Regions = new RegionsClient(_connection); Sizes = new SizesClient(_connection); Tags = new TagsClient(_connection); }