public async Task BindAsyncError() { var request = new ServiceBindingRequest { ServiceId = "abc", PlanId = "xyz" }; var response = new ServiceBindingAsyncOperation { Operation = "my operation" }; var operation = new LastOperationResource { State = LastOperationResourceState.Failed, Description = "custom message" }; Mock.Setup(x => x.BindAsync(new("123", "456"), request)) .ReturnsAsync(response); Mock.Setup(x => x.GetLastOperationAsync(new("123", "456"), "abc", "xyz", "my operation")) .ReturnsAsync(operation); await Client.ServiceInstancesPolling["123"].ServiceBindings["456"] .Awaiting(x => x.BindAsync(request)) .Should().ThrowAsync <BrokerException>().WithMessage("custom message"); }
public async Task BindCompleted() { var request = new ServiceBindingRequest { ServiceId = "abc", PlanId = "xyz" }; var response = new ServiceBindingAsyncOperation().Complete(new ServiceBinding()); SetupMock(x => x.BindAsync(new ServiceBindingContext("123", "456"), request), response); var result = await Client.ServiceInstancesDeferred["123"].ServiceBindings["456"].BindAsync(request); result.Should().BeEquivalentTo(response); }
public async Task BindUnchanged() { var request = new ServiceBindingRequest { ServiceId = "abc", PlanId = "xyz" }; var response = new ServiceBindingAsyncOperation().Complete(new ServiceBinding { Unchanged = true }); Mock.Setup(x => x.BindAsync(new("123", "456"), request)) .ReturnsAsync(response); var result = await Client.ServiceInstancesDeferred["123"].ServiceBindings["456"].BindAsync(request); result.Should().BeEquivalentTo(response); }
public async Task BindCompleted() { var request = new ServiceBindingRequest { ServiceId = "abc", PlanId = "xyz" }; var syntheticResponse = new ServiceBinding { RouteServiceUrl = new Uri("http://example.com") }; var response = new ServiceBindingAsyncOperation().Complete(syntheticResponse); SetupMock(x => x.BindAsync(new ServiceBindingContext("123", "456"), request), response); var result = await Client.ServiceInstancesPolling["123"].ServiceBindings["456"].BindAsync(request); result.Should().BeEquivalentTo(syntheticResponse); }
public async Task BindDeferred() { var request = new ServiceBindingRequest { ServiceId = "abc", PlanId = "xyz", BindResource = new ServiceBindingResourceObject { AppGuid = "123-456" } }; var response = new ServiceBindingAsyncOperation { Operation = "my operation" }; SetupMock(x => x.BindAsync(new ServiceBindingContext("123", "456"), request), response); var result = await Client.ServiceInstancesDeferred["123"].ServiceBindings["456"].BindAsync(request); result.Should().BeEquivalentTo(response); }
public async Task BindDeferred() { var request = new ServiceBindingRequest { ServiceId = "abc", PlanId = "xyz", BindResource = new() { AppGuid = "123-456" } }; var response = new ServiceBindingAsyncOperation { Operation = "my operation" }; var operation = new LastOperationResource { State = LastOperationResourceState.Succeeded, Description = "done" }; var resource = new ServiceBindingResource { RouteServiceUrl = new Uri("http://example.com") }; var syntheticResponse = new ServiceBinding { RouteServiceUrl = new Uri("http://example.com") }; Mock.Setup(x => x.BindAsync(new("123", "456"), request)) .ReturnsAsync(response); Mock.Setup(x => x.GetLastOperationAsync(new("123", "456"), "abc", "xyz", "my operation")) .ReturnsAsync(operation); Mock.Setup(x => x.FetchAsync("123", "456")) .ReturnsAsync(resource); var result = await Client.ServiceInstancesPolling["123"].ServiceBindings["456"].BindAsync(request); result.Should().BeEquivalentTo(syntheticResponse); }