public async Task ProvisionDeferred()
        {
            var request = new ServiceInstanceProvisionRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation
            {
                Operation    = "my operation",
                DashboardUrl = new Uri("http://example.com")
            };
            var operation = new LastOperationResource
            {
                State       = LastOperationResourceState.Succeeded,
                Description = "done"
            };
            var syntheticResponse = new ServiceInstanceProvision
            {
                DashboardUrl = response.DashboardUrl
            };

            SetupMock(x => x.ProvisionAsync(new ServiceInstanceContext("123"), request), response);
            SetupMock(x => x.GetLastOperationAsync(new ServiceInstanceContext("123"), "abc", "xyz", "my operation"), operation);
            var result = await Client.ServiceInstancesPolling["123"].ProvisionAsync(request);

            result.Should().BeEquivalentTo(syntheticResponse);
        }
        public async Task ProvisionAsyncError()
        {
            var request = new ServiceInstanceProvisionRequest
            {
                ServiceId        = "abc",
                PlanId           = "xyz",
                OrganizationGuid = "org",
                SpaceGuid        = "space"
            };
            var response = new ServiceInstanceAsyncOperation
            {
                Operation = "my operation"
            };
            var operation = new LastOperationResource
            {
                State       = LastOperationResourceState.Failed,
                Description = "custom message"
            };

            Mock.Setup(x => x.ProvisionAsync(new("123"), request))
            .ReturnsAsync(response);
            Mock.Setup(x => x.GetLastOperationAsync(new("123"), "abc", "xyz", "my operation"))
            .ReturnsAsync(operation);
            await Client.ServiceInstancesPolling["123"]
            .Awaiting(x => x.ProvisionAsync(request))
            .Should().ThrowAsync <BrokerException>().WithMessage("custom message");
        }
        public void DeprovisionAsyncGone()
        {
            var response = new ServiceInstanceAsyncOperation
            {
                Operation = "my operation"
            };

            SetupMock(x => x.DeprovisionAsync(new ServiceInstanceContext("123"), "abc", "xyz"), response);
            SetupMock(x => x.GetLastOperationAsync(new ServiceInstanceContext("123"), "abc", "xyz", "my operation"), new GoneException());
            Client.ServiceInstancesPolling["123"].Awaiting(x => x.DeprovisionAsync("abc", "xyz")).Should().Throw <GoneException>();
        }
        public async Task UpdateCompleted()
        {
            var request = new ServiceInstanceUpdateRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation();

            SetupMock(x => x.UpdateAsync(new ServiceInstanceContext("123"), request), response);
            await Client.ServiceInstancesPolling["123"].UpdateAsync(request);
        }
Ejemplo n.º 5
0
        public async Task UpdateCompleted()
        {
            var request = new ServiceInstanceUpdateRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation();

            SetupMock(x => x.UpdateAsync(new ServiceInstanceContext("123"), request), response);
            var result = await Client.ServiceInstancesDeferred["123"].UpdateAsync(request);

            result.Should().BeEquivalentTo(response);
        }
        public async Task DeprovisionAsyncGone()
        {
            var response = new ServiceInstanceAsyncOperation
            {
                Operation = "my operation"
            };

            Mock.Setup(x => x.DeprovisionAsync(new("123"), "abc", "xyz"))
            .ReturnsAsync(response);
            Mock.Setup((x => x.GetLastOperationAsync(new("123"), "abc", "xyz", "my operation")))
            .Throws <GoneException>();
            await Client.ServiceInstancesPolling["123"]
            .Awaiting(x => x.DeprovisionAsync("abc", "xyz"))
            .Should().ThrowAsync <GoneException>();
        }
Ejemplo n.º 7
0
        public async Task ProvisionCompleted()
        {
            var request = new ServiceInstanceProvisionRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation().Complete(new ServiceInstanceProvision
            {
                DashboardUrl = new Uri("http://example.com")
            });

            SetupMock(x => x.ProvisionAsync(new ServiceInstanceContext("123"), request), response);
            var result = await Client.ServiceInstancesDeferred["123"].ProvisionAsync(request);

            result.Should().BeEquivalentTo(response);
        }
Ejemplo n.º 8
0
        public async Task UpdateDeferred()
        {
            var request = new ServiceInstanceUpdateRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation
            {
                Operation    = "my operation",
                DashboardUrl = new Uri("http://example.com")
            };

            SetupMock(x => x.UpdateAsync(new ServiceInstanceContext("123"), request), response);
            var result = await Client.ServiceInstancesDeferred["123"].UpdateAsync(request);

            result.Should().BeEquivalentTo(response);
        }
        public async Task ProvisionCompleted()
        {
            var request = new ServiceInstanceProvisionRequest
            {
                ServiceId        = "abc",
                PlanId           = "xyz",
                OrganizationGuid = "org",
                SpaceGuid        = "space"
            };
            var response = new ServiceInstanceAsyncOperation().Complete(new ServiceInstanceProvision
            {
                DashboardUrl = new Uri("http://example.com")
            });

            Mock.Setup(x => x.ProvisionAsync(new("123"), request))
            .ReturnsAsync(response);
            var result = await Client.ServiceInstancesDeferred["123"].ProvisionAsync(request);

            result.Should().BeEquivalentTo(response);
        }
        public async Task ProvisionCompleted()
        {
            var request = new ServiceInstanceProvisionRequest
            {
                ServiceId        = "abc",
                PlanId           = "xyz",
                OrganizationGuid = "org",
                SpaceGuid        = "space"
            };
            var syntheticResponse = new ServiceInstanceProvision
            {
                DashboardUrl = new Uri("http://example.com")
            };
            var response = new ServiceInstanceAsyncOperation().Complete(syntheticResponse);

            SetupMock(x => x.ProvisionAsync(new ServiceInstanceContext("123"), request), response);
            var result = await Client.ServiceInstancesPolling["123"].ProvisionAsync(request);

            result.Should().BeEquivalentTo(syntheticResponse);
        }
        public async Task UpdateDeferred()
        {
            var request = new ServiceInstanceUpdateRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation
            {
                Operation = "my operation"
            };
            var operation = new LastOperationResource
            {
                State       = LastOperationResourceState.Succeeded,
                Description = "done"
            };

            SetupMock(x => x.UpdateAsync(new ServiceInstanceContext("123"), request), response);
            SetupMock(x => x.GetLastOperationAsync(new ServiceInstanceContext("123"), "abc", "xyz", "my operation"), operation);
            await Client.ServiceInstancesPolling["123"].UpdateAsync(request);
        }
        public void ProvisionAsyncError()
        {
            var request = new ServiceInstanceProvisionRequest
            {
                ServiceId = "abc",
                PlanId    = "xyz"
            };
            var response = new ServiceInstanceAsyncOperation
            {
                Operation = "my operation"
            };
            var operation = new LastOperationResource
            {
                State       = LastOperationResourceState.Failed,
                Description = "custom message"
            };

            SetupMock(x => x.ProvisionAsync(new ServiceInstanceContext("123"), request), response);
            SetupMock(x => x.GetLastOperationAsync(new ServiceInstanceContext("123"), "abc", "xyz", "my operation"), operation);
            Client.ServiceInstancesPolling["123"].Awaiting(x => x.ProvisionAsync(request)).Should().Throw <BrokerException>().WithMessage("custom message");
        }
Ejemplo n.º 13
0
 public bool Equals(ServiceInstanceAsyncOperation other)
 => other != null &&
 base.Equals(other) &&
 DashboardUrl == other.DashboardUrl &&
 Equals(Result, other.Result);