Exemplo n.º 1
0
        public async stt::Task UndeleteAlertRequestObjectAsync()
        {
            moq::Mock <AlertCenterService.AlertCenterServiceClient> mockGrpcClient = new moq::Mock <AlertCenterService.AlertCenterServiceClient>(moq::MockBehavior.Strict);
            UndeleteAlertRequest request = new UndeleteAlertRequest
            {
                CustomerId = "customer_id3b3724cb",
                AlertId    = "alert_idc6c58cd5",
            };
            Alert expectedResponse = new Alert
            {
                CustomerId = "customer_id3b3724cb",
                AlertId    = "alert_idc6c58cd5",
                CreateTime = new wkt::Timestamp(),
                StartTime  = new wkt::Timestamp(),
                EndTime    = new wkt::Timestamp(),
                Type       = "typee2cc9d59",
                Source     = "sourcef438cd36",
                Data       = new wkt::Any(),
                SecurityInvestigationToolLink = "security_investigation_tool_linked92158f",
                Deleted    = true,
                Metadata   = new AlertMetadata(),
                UpdateTime = new wkt::Timestamp(),
                Etag       = "etage8ad7218",
            };

            mockGrpcClient.Setup(x => x.UndeleteAlertAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Alert>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            AlertCenterServiceClient client = new AlertCenterServiceClientImpl(mockGrpcClient.Object, null);
            Alert responseCallSettings      = await client.UndeleteAlertAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Alert responseCancellationToken = await client.UndeleteAlertAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }