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 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(); }