public void GetOccurrence2()
        {
            Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict);
            GetOccurrenceRequest         request        = new GetOccurrenceRequest
            {
                OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"),
            };
            Occurrence expectedResponse = new Occurrence
            {
                OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"),
                ResourceUri    = "resourceUri-384040517",
                NoteName       = "noteName1780787896",
                Remediation    = "remediation779381797",
            };

            mockGrpcClient.Setup(x => x.GetOccurrence(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GrafeasClient client   = new GrafeasClientImpl(mockGrpcClient.Object, null);
            Occurrence    response = client.GetOccurrence(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#2
0
        public void UpdateNote2()
        {
            Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict);
            UpdateNoteRequest            request        = new UpdateNoteRequest
            {
                NoteName = new NoteName("[PROJECT]", "[NOTE]"),
                Note     = new Note(),
            };
            Note expectedResponse = new Note
            {
                NoteName         = new NoteName("[PROJECT]", "[NOTE]"),
                ShortDescription = "shortDescription-235369287",
                LongDescription  = "longDescription-1747792199",
            };

            mockGrpcClient.Setup(x => x.UpdateNote(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GrafeasClient client   = new GrafeasClientImpl(mockGrpcClient.Object, null);
            Note          response = client.UpdateNote(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async Task GetNoteAsync()
        {
            Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict);
            GetNoteRequest expectedRequest = new GetNoteRequest
            {
                NoteName = new NoteName("[PROJECT]", "[NOTE]"),
            };
            Note expectedResponse = new Note
            {
                NoteName         = new NoteName("[PROJECT]", "[NOTE]"),
                ShortDescription = "shortDescription-235369287",
                LongDescription  = "longDescription-1747792199",
            };

            mockGrpcClient.Setup(x => x.GetNoteAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Note>(Task.FromResult(expectedResponse), null, null, null, null));
            GrafeasClient client   = new GrafeasClientImpl(mockGrpcClient.Object, null);
            NoteName      name     = new NoteName("[PROJECT]", "[NOTE]");
            Note          response = await client.GetNoteAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
示例#4
0
        public async Task GetOccurrenceAsync()
        {
            Mock <Grafeas.GrafeasClient> mockGrpcClient  = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict);
            GetOccurrenceRequest         expectedRequest = new GetOccurrenceRequest
            {
                OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"),
            };
            Occurrence expectedResponse = new Occurrence
            {
                OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"),
                ResourceUri    = "resourceUri-384040517",
                NoteName       = "noteName1780787896",
                Remediation    = "remediation779381797",
            };

            mockGrpcClient.Setup(x => x.GetOccurrenceAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Occurrence>(Task.FromResult(expectedResponse), null, null, null, null));
            GrafeasClient  client   = new GrafeasClientImpl(mockGrpcClient.Object, null);
            OccurrenceName name     = new OccurrenceName("[PROJECT]", "[OCCURRENCE]");
            Occurrence     response = await client.GetOccurrenceAsync(name);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }