상속: IDropletsClient
예제 #1
0
        public void CorrectRequestForGetAll() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            client.GetAll();

            factory.Received().GetPaginated<Droplet>("droplets", null, "droplets");
        }
예제 #2
0
        public void CorrectRequestForCreate() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            var body = new Models.Requests.Droplet();
            client.Create(body);

            factory.Received().ExecuteRequest<Droplet>("droplets", null, body, "droplet", Method.POST);
        }
예제 #3
0
        public void CorrectRequestForGetActions() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            client.GetActions(9001);

            var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
            factory.Received().GetPaginated<Action>("droplets/{id}/actions", parameters, "actions");
        }
예제 #4
0
        public void CorrectRequestForGetAllByTag() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            client.GetAllByTag("notarealtag");

            var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "notarealtag");
            factory.Received().GetPaginated<Droplet>("droplets?tag_name={name}", parameters, "droplets");
        }
        public void CorrectRequestForGet() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            client.Get(9001);

            var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
            factory.Received().ExecuteRequest<Droplet>("droplets/{id}", parameters, null, "droplet");
        }
        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);
        }
예제 #7
0
        public void CorrectRequestForDeleteByTag() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            client.DeleteByTag("notarealtag");

            var parameters = Arg.Is<List<Parameter>>(list => (string)list[0].Value == "notarealtag");
            factory.Received().ExecuteRaw("droplets?tag_name={name}", parameters, null, Method.DELETE);
        }
        public void CorrectRequestForDelete() {
            var factory = Substitute.For<IConnection>();
            var client = new DropletsClient(factory);

            client.Delete(9001);

            var parameters = Arg.Is<List<Parameter>>(list => (int)list[0].Value == 9001);
            factory.Received().ExecuteRaw("droplets/{id}", parameters, Method.DELETE);
        }