public async Task SetAgentAsync() { Mock <Agents.AgentsClient> mockGrpcClient = new Mock <Agents.AgentsClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); SetAgentRequest expectedRequest = new SetAgentRequest { Agent = new Agent(), }; Agent expectedResponse = new Agent { Parent = "parent-995424086", DisplayName = "displayName1615086568", DefaultLanguageCode = "defaultLanguageCode856575222", TimeZone = "timeZone36848094", Description = "description-1724546052", AvatarUri = "avatarUri-402824826", EnableLogging = false, ClassificationThreshold = 1.11581064E8f, }; mockGrpcClient.Setup(x => x.SetAgentAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Agent>(Task.FromResult(expectedResponse), null, null, null, null)); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent agent = new Agent(); Agent response = await client.SetAgentAsync(agent); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void SetAgent() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); SetAgentRequest request = new SetAgentRequest { Agent = new Agent(), }; Agent expectedResponse = new Agent { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), DisplayName = "display_name137f65c2", DefaultLanguageCode = "default_language_codee612e130", SupportedLanguageCodes = { "supported_language_codesbcd806b9", }, TimeZone = "time_zone73f23b20", Description = "description2cf9da67", AvatarUri = "avatar_urie1767db7", EnableLogging = false, MatchMode = Agent.Types.MatchMode.MlOnly, ClassificationThreshold = -7.68696135E+17F, ApiVersion = Agent.Types.ApiVersion.V2Beta1, Tier = Agent.Types.Tier.Standard, }; mockGrpcClient.Setup(x => x.SetAgent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent response = client.SetAgent(request.Agent); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetAgent2() { Mock <Agents.AgentsClient> mockGrpcClient = new Mock <Agents.AgentsClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); GetAgentRequest request = new GetAgentRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), }; Agent expectedResponse = new Agent { Parent = "parent21175163357", DisplayName = "displayName1615086568", DefaultLanguageCode = "defaultLanguageCode856575222", TimeZone = "timeZone36848094", Description = "description-1724546052", AvatarUri = "avatarUri-402824826", EnableLogging = false, ClassificationThreshold = 1.11581064E8f, }; mockGrpcClient.Setup(x => x.GetAgent(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent response = client.GetAgent(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task UpdateAgentAsync() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); UpdateAgentRequest request = new UpdateAgentRequest { Agent = new Agent(), UpdateMask = new wkt::FieldMask(), }; Agent expectedResponse = new Agent { AgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), DisplayName = "display_name137f65c2", DefaultLanguageCode = "default_language_codee612e130", TimeZone = "time_zone73f23b20", Description = "description2cf9da67", AvatarUri = "avatar_urie1767db7", SpeechToTextSettings = new SpeechToTextSettings(), StartFlowAsFlowName = FlowName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]"), EnableStackdriverLogging = false, EnableSpellCorrection = true, }; mockGrpcClient.Setup(x => x.UpdateAgentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Agent>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent responseCallSettings = await client.UpdateAgentAsync(request.Agent, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Agent responseCancellationToken = await client.UpdateAgentAsync(request.Agent, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetAgent() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetAgentRequest request = new GetAgentRequest { AgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), }; Agent expectedResponse = new Agent { AgentName = AgentName.FromProjectLocationAgent("[PROJECT]", "[LOCATION]", "[AGENT]"), DisplayName = "display_name137f65c2", DefaultLanguageCode = "default_language_codee612e130", TimeZone = "time_zone73f23b20", Description = "description2cf9da67", AvatarUri = "avatar_urie1767db7", SpeechToTextSettings = new SpeechToTextSettings(), StartFlowAsFlowName = FlowName.FromProjectLocationAgentFlow("[PROJECT]", "[LOCATION]", "[AGENT]", "[FLOW]"), EnableStackdriverLogging = false, EnableSpellCorrection = true, }; mockGrpcClient.Setup(x => x.GetAgent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent response = client.GetAgent(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetValidationResultRequestObjectAsync() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetValidationResultRequest request = new GetValidationResultRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), LanguageCode = "language_code2f6c7160", }; ValidationResult expectedResponse = new ValidationResult { ValidationErrors = { new ValidationError(), }, }; mockGrpcClient.Setup(x => x.GetValidationResultAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ValidationResult>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); ValidationResult responseCallSettings = await client.GetValidationResultAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); ValidationResult responseCancellationToken = await client.GetValidationResultAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetValidationResultRequestObject() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetValidationResultRequest request = new GetValidationResultRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), LanguageCode = "language_code2f6c7160", }; ValidationResult expectedResponse = new ValidationResult { ValidationErrors = { new ValidationError(), }, }; mockGrpcClient.Setup(x => x.GetValidationResult(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); ValidationResult response = client.GetValidationResult(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task DeleteAgentAsync() { Mock <Agents.AgentsClient> mockGrpcClient = new Mock <Agents.AgentsClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); DeleteAgentRequest request = new DeleteAgentRequest(); Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteAgentAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Empty>(Task.FromResult(expectedResponse), null, null, null, null)); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); await client.DeleteAgentAsync(request); mockGrpcClient.VerifyAll(); }
public void DeleteAgent() { Mock <Agents.AgentsClient> mockGrpcClient = new Mock <Agents.AgentsClient>(MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()) .Returns(new Mock <Operations.OperationsClient>().Object); DeleteAgentRequest request = new DeleteAgentRequest(); Empty expectedResponse = new Empty(); mockGrpcClient.Setup(x => x.DeleteAgent(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); client.DeleteAgent(request); mockGrpcClient.VerifyAll(); }
public void DeleteAgentResourceNames() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); DeleteAgentRequest request = new DeleteAgentRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteAgent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); client.DeleteAgent(request.ParentAsProjectName); mockGrpcClient.VerifyAll(); }
public async stt::Task DeleteAgentResourceNamesAsync() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); DeleteAgentRequest request = new DeleteAgentRequest { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), }; wkt::Empty expectedResponse = new wkt::Empty { }; mockGrpcClient.Setup(x => x.DeleteAgentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); await client.DeleteAgentAsync(request.ParentAsProjectName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); await client.DeleteAgentAsync(request.ParentAsProjectName, st::CancellationToken.None); mockGrpcClient.VerifyAll(); }
public async stt::Task SetAgentRequestObjectAsync() { moq::Mock <Agents.AgentsClient> mockGrpcClient = new moq::Mock <Agents.AgentsClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); SetAgentRequest request = new SetAgentRequest { Agent = new Agent(), UpdateMask = new wkt::FieldMask(), }; Agent expectedResponse = new Agent { ParentAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"), DisplayName = "display_name137f65c2", DefaultLanguageCode = "default_language_codee612e130", SupportedLanguageCodes = { "supported_language_codesbcd806b9", }, TimeZone = "time_zone73f23b20", Description = "description2cf9da67", AvatarUri = "avatar_urie1767db7", EnableLogging = false, #pragma warning disable CS0612 MatchMode = Agent.Types.MatchMode.MlOnly, #pragma warning restore CS0612 ClassificationThreshold = -7.6869614E+17F, ApiVersion = Agent.Types.ApiVersion.V2Beta1, Tier = Agent.Types.Tier.Standard, }; mockGrpcClient.Setup(x => x.SetAgentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Agent>(stt::Task.FromResult(expectedResponse), null, null, null, null)); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent responseCallSettings = await client.SetAgentAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Agent responseCancellationToken = await client.SetAgentAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }