public async stt::Task CreateCallRequestObjectAsync() { moq::Mock <Calls.CallsClient> mockGrpcClient = new moq::Mock <Calls.CallsClient>(moq::MockBehavior.Strict); CreateCallRequest request = new CreateCallRequest { ParentAsProjectName = ProjectName.FromProject("[PROJECT]"), Call = new Call(), }; Call expectedResponse = new Call { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), To = "to03e2b601", From = "fromf8078ad9", IsPrivate = false, Labels = { { "key8a0b6e3c", "value60c16320" }, }, Transport = Call.Types.Transport.Sip, Direction = Call.Types.Direction.Incoming, ErrorCode = "error_code42bd958e", ErrorMessage = "error_messaged73952bd", Price = new gt::Money(), State = Call.Types.State.Busy, CreateTime = new wkt::Timestamp(), StartTime = new wkt::Timestamp(), RingTime = new wkt::Timestamp(), AnswerTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), Bridged = true, OriginatingCall = "originating_call9e182b53", CreateMethod = Call.Types.CreateMethod.Api, Options = new Call.Types.ApiCallOptions(), }; mockGrpcClient.Setup(x => x.CreateCallAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Call>(stt::Task.FromResult(expectedResponse), null, null, null, null)); CallsClient client = new CallsClientImpl(mockGrpcClient.Object, null); Call responseCallSettings = await client.CreateCallAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Call responseCancellationToken = await client.CreateCallAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetCallResourceNames() { moq::Mock <Calls.CallsClient> mockGrpcClient = new moq::Mock <Calls.CallsClient>(moq::MockBehavior.Strict); GetCallRequest request = new GetCallRequest { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), }; Call expectedResponse = new Call { CallName = CallName.FromProjectCall("[PROJECT]", "[CALL]"), To = "to03e2b601", From = "fromf8078ad9", IsPrivate = false, Labels = { { "key8a0b6e3c", "value60c16320" }, }, Transport = Call.Types.Transport.Sip, Direction = Call.Types.Direction.Incoming, ErrorCode = "error_code42bd958e", ErrorMessage = "error_messaged73952bd", Price = new gt::Money(), State = Call.Types.State.Busy, CreateTime = new wkt::Timestamp(), StartTime = new wkt::Timestamp(), RingTime = new wkt::Timestamp(), AnswerTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), Bridged = true, OriginatingCall = "originating_call9e182b53", CreateMethod = Call.Types.CreateMethod.Api, Options = new Call.Types.ApiCallOptions(), }; mockGrpcClient.Setup(x => x.GetCall(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); CallsClient client = new CallsClientImpl(mockGrpcClient.Object, null); Call response = client.GetCall(request.CallName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }