Beispiel #1
0
        public void SetUp()
        {
            clientFactory = Substitute.For <IOctopusClientFactory>();
            client        = Substitute.For <IOctopusClient>();
            clientFactory.CreateClient(Arg.Any <OctopusServerEndpoint>()).Returns(client);
            operation      = new RegisterMachineOperation(clientFactory);
            serverEndpoint = new OctopusServerEndpoint("http://octopus", "ABC123");

            environments = new ResourceCollection <EnvironmentResource>(new EnvironmentResource[0], LinkCollection.Self("/foo"));
            machines     = new ResourceCollection <MachineResource>(new MachineResource[0], LinkCollection.Self("/foo"));
            client.RootDocument.Returns(new RootResource {
                Links = LinkCollection.Self("/api").Add("Environments", "/api/environments").Add("Machines", "/api/machines")
            });

            client.When(x => x.Paginate(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <Func <ResourceCollection <EnvironmentResource>, bool> >()))
            .Do(ci => ci.Arg <Func <ResourceCollection <EnvironmentResource>, bool> >()(environments));

            client.When(x => x.Paginate(Arg.Any <string>(), Arg.Any <object>(), Arg.Any <Func <ResourceCollection <MachineResource>, bool> >()))
            .Do(ci => ci.Arg <Func <ResourceCollection <MachineResource>, bool> >()(machines));

            client.List <MachineResource>(Arg.Any <string>(), Arg.Any <object>()).Returns(machines);
        }
 public ResourceCollection <PackageFromBuiltInFeedResource> ListPackages(string packageId, int skip = 0, int take = 30)
 {
     return(client.List <PackageFromBuiltInFeedResource>(client.RootDocument.Link("Packages"), new { nuGetPackageId = packageId, take, skip }));
 }