public async stt::Task GetSpokeResourceNamesAsync() { moq::Mock <HubService.HubServiceClient> mockGrpcClient = new moq::Mock <HubService.HubServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetSpokeRequest request = new GetSpokeRequest { SpokeName = SpokeName.FromProjectLocationSpoke("[PROJECT]", "[LOCATION]", "[SPOKE]"), }; Spoke expectedResponse = new Spoke { SpokeName = SpokeName.FromProjectLocationSpoke("[PROJECT]", "[LOCATION]", "[SPOKE]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", HubAsHubName = HubName.FromProjectHub("[PROJECT]", "[HUB]"), UniqueId = "unique_idee0c0869", LinkedVpnTunnelsAsVpnTunnelNames = { VpnTunnelName.FromProjectRegionResource("[PROJECT]", "[REGION]", "[RESOURCE_ID]"), }, LinkedInterconnectAttachmentsAsInterconnectAttachmentNames = { InterconnectAttachmentName.FromProjectRegionResource("[PROJECT]", "[REGION]", "[RESOURCE_ID]"), }, LinkedRouterApplianceInstances = { new RouterApplianceInstance(), }, State = State.Active, }; mockGrpcClient.Setup(x => x.GetSpokeAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Spoke>(stt::Task.FromResult(expectedResponse), null, null, null, null)); HubServiceClient client = new HubServiceClientImpl(mockGrpcClient.Object, null); Spoke responseCallSettings = await client.GetSpokeAsync(request.SpokeName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Spoke responseCancellationToken = await client.GetSpokeAsync(request.SpokeName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async stt::Task GetHubRequestObjectAsync() { moq::Mock <HubService.HubServiceClient> mockGrpcClient = new moq::Mock <HubService.HubServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetHubRequest request = new GetHubRequest { HubName = HubName.FromProjectHub("[PROJECT]", "[HUB]"), }; Hub expectedResponse = new Hub { HubName = HubName.FromProjectHub("[PROJECT]", "[HUB]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", SpokesAsSpokeNames = { SpokeName.FromProjectLocationSpoke("[PROJECT]", "[LOCATION]", "[SPOKE]"), }, UniqueId = "unique_idee0c0869", State = State.Active, }; mockGrpcClient.Setup(x => x.GetHubAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Hub>(stt::Task.FromResult(expectedResponse), null, null, null, null)); HubServiceClient client = new HubServiceClientImpl(mockGrpcClient.Object, null); Hub responseCallSettings = await client.GetHubAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Hub responseCancellationToken = await client.GetHubAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetHubResourceNames() { moq::Mock <HubService.HubServiceClient> mockGrpcClient = new moq::Mock <HubService.HubServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetHubRequest request = new GetHubRequest { HubName = HubName.FromProjectHub("[PROJECT]", "[HUB]"), }; Hub expectedResponse = new Hub { HubName = HubName.FromProjectHub("[PROJECT]", "[HUB]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", SpokesAsSpokeNames = { SpokeName.FromProjectLocationSpoke("[PROJECT]", "[LOCATION]", "[SPOKE]"), }, UniqueId = "unique_idee0c0869", State = State.Active, }; mockGrpcClient.Setup(x => x.GetHub(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); HubServiceClient client = new HubServiceClientImpl(mockGrpcClient.Object, null); Hub response = client.GetHub(request.HubName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetSpokeRequestObject() { moq::Mock <HubService.HubServiceClient> mockGrpcClient = new moq::Mock <HubService.HubServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetSpokeRequest request = new GetSpokeRequest { SpokeName = SpokeName.FromProjectLocationSpoke("[PROJECT]", "[LOCATION]", "[SPOKE]"), }; Spoke expectedResponse = new Spoke { SpokeName = SpokeName.FromProjectLocationSpoke("[PROJECT]", "[LOCATION]", "[SPOKE]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, Description = "description2cf9da67", HubAsHubName = HubName.FromProjectHub("[PROJECT]", "[HUB]"), UniqueId = "unique_idee0c0869", State = State.Active, LinkedVpnTunnels = new LinkedVpnTunnels(), LinkedInterconnectAttachments = new LinkedInterconnectAttachments(), LinkedRouterApplianceInstances = new LinkedRouterApplianceInstances(), }; mockGrpcClient.Setup(x => x.GetSpoke(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); HubServiceClient client = new HubServiceClientImpl(mockGrpcClient.Object, null); Spoke response = client.GetSpoke(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }