public async stt::Task GetTestCaseResourceNamesAsync() { moq::Mock <TestCases.TestCasesClient> mockGrpcClient = new moq::Mock <TestCases.TestCasesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTestCaseRequest request = new GetTestCaseRequest { TestCaseName = TestCaseName.FromProjectLocationAgentTestCase("[PROJECT]", "[LOCATION]", "[AGENT]", "[TEST_CASE]"), }; TestCase expectedResponse = new TestCase { TestCaseName = TestCaseName.FromProjectLocationAgentTestCase("[PROJECT]", "[LOCATION]", "[AGENT]", "[TEST_CASE]"), Tags = { "tags52c47ad5", }, DisplayName = "display_name137f65c2", Notes = "notes00b55843", TestCaseConversationTurns = { new ConversationTurn(), }, CreationTime = new wkt::Timestamp(), LastTestResult = new TestCaseResult(), TestConfig = new TestConfig(), }; mockGrpcClient.Setup(x => x.GetTestCaseAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <TestCase>(stt::Task.FromResult(expectedResponse), null, null, null, null)); TestCasesClient client = new TestCasesClientImpl(mockGrpcClient.Object, null); TestCase responseCallSettings = await client.GetTestCaseAsync(request.TestCaseName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); TestCase responseCancellationToken = await client.GetTestCaseAsync(request.TestCaseName, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetTestCase() { moq::Mock <TestCases.TestCasesClient> mockGrpcClient = new moq::Mock <TestCases.TestCasesClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetTestCaseRequest request = new GetTestCaseRequest { TestCaseName = TestCaseName.FromProjectLocationAgentTestCase("[PROJECT]", "[LOCATION]", "[AGENT]", "[TEST_CASE]"), }; TestCase expectedResponse = new TestCase { TestCaseName = TestCaseName.FromProjectLocationAgentTestCase("[PROJECT]", "[LOCATION]", "[AGENT]", "[TEST_CASE]"), Tags = { "tags52c47ad5", }, DisplayName = "display_name137f65c2", Notes = "notes00b55843", TestCaseConversationTurns = { new ConversationTurn(), }, CreationTime = new wkt::Timestamp(), LastTestResult = new TestCaseResult(), TestConfig = new TestConfig(), }; mockGrpcClient.Setup(x => x.GetTestCase(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TestCasesClient client = new TestCasesClientImpl(mockGrpcClient.Object, null); TestCase response = client.GetTestCase(request.Name); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }