public async stt::Task CheckBuildStageStatusRequestObjectAsync() { moq::Mock <BuildService.BuildServiceClient> mockGrpcClient = new moq::Mock <BuildService.BuildServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); CheckBuildStageStatusRequest request = new CheckBuildStageStatusRequest { BuildArtifactName = BuildArtifactName.FromBuildTargetModelBuildArtifact("[BUILD_TARGET]", "[MODEL]", "[BUILD]", "[ARTIFACT]"), Filter = "filtere47ac9b2", }; CheckBuildStageStatusResponse expectedResponse = new CheckBuildStageStatusResponse { IsBuildStaged = false, StagedBuildArtifact = new BuildArtifact(), SourceBuildArtifact = new BuildArtifact(), }; mockGrpcClient.Setup(x => x.CheckBuildStageStatusAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <CheckBuildStageStatusResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); BuildServiceClient client = new BuildServiceClientImpl(mockGrpcClient.Object, null); CheckBuildStageStatusResponse responseCallSettings = await client.CheckBuildStageStatusAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); CheckBuildStageStatusResponse responseCancellationToken = await client.CheckBuildStageStatusAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void CheckBuildStageStatus() { moq::Mock <BuildService.BuildServiceClient> mockGrpcClient = new moq::Mock <BuildService.BuildServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); CheckBuildStageStatusRequest request = new CheckBuildStageStatusRequest { BuildArtifactName = BuildArtifactName.FromBuildTargetModelBuildArtifact("[BUILD_TARGET]", "[MODEL]", "[BUILD]", "[ARTIFACT]"), }; CheckBuildStageStatusResponse expectedResponse = new CheckBuildStageStatusResponse { IsBuildStaged = false, StagedBuildArtifact = new BuildArtifact(), SourceBuildArtifact = new BuildArtifact(), }; mockGrpcClient.Setup(x => x.CheckBuildStageStatus(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); BuildServiceClient client = new BuildServiceClientImpl(mockGrpcClient.Object, null); CheckBuildStageStatusResponse response = client.CheckBuildStageStatus(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }