public void CorrectRequestForGetAction() { var factory = Substitute.For<IConnection>(); var client = new ImageActionsClient(factory); client.GetAction(9001, 1009); var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001 && (int)list[1].Value == 1009); factory.Received().ExecuteRequest<Models.Responses.Action>("images/{imageId}/actions/{actionId}", parameters, null, "action"); }
public void CorrectRequestForTransfer() { var factory = Substitute.For<IConnection>(); var client = new ImageActionsClient(factory); client.Transfer(9001, "sfo1"); var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001); var body = Arg.Is<Action>(action => action.Type == "transfer" && action.RegionSlug == "sfo1"); factory.Received().ExecuteRequest<Models.Responses.Action>("images/{imageId}/actions", parameters, body, "action", Method.POST); }
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); }