public void SetAgent() { 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.SetAgent(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); AgentsClient client = new AgentsClientImpl(mockGrpcClient.Object, null); Agent agent = new Agent(); Agent response = client.SetAgent(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(); }