public void CorrectRequestForGetAll() { var factory = Substitute.For<IConnection>(); var client = new KeysClient(factory); client.GetAll(); factory.Received().GetPaginated<Key>("account/keys", null, "ssh_keys"); }
public void CorrectRequestForDeleteId() { var factory = Substitute.For<IConnection>(); var client = new KeysClient(factory); client.Delete(9001); var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001); factory.Received().ExecuteRaw("account/keys/{id}", parameters, Method.DELETE); }
public void CorrectRequestForGetFingerprint() { var factory = Substitute.For<IConnection>(); var client = new KeysClient(factory); client.Get("fingerprint"); var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "fingerprint"); factory.Received().ExecuteRequest<Key>("account/keys/{id}", parameters, null, "ssh_key"); }
public void CorrectRequestForCreate() { var factory = Substitute.For<IConnection>(); var client = new KeysClient(factory); var body = new Models.Requests.Key { Name = "example" }; client.Create(body); factory.Received().ExecuteRequest<Key>("account/keys", null, body, "ssh_key", Method.POST); }
public void CorrectRequestForUpdateFingerprint() { var factory = Substitute.For<IConnection>(); var client = new KeysClient(factory); var body = new Models.Requests.Key { Name = "example" }; client.Update("fingerprint", body); var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "fingerprint"); factory.Received().ExecuteRequest<Key>("account/keys/{id}", parameters, body, "ssh_key", Method.PUT); }
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); }