public async Task CreateOccurrenceAsync()
        {
            Mock <Grafeas.GrafeasClient> mockGrpcClient  = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict);
            CreateOccurrenceRequest      expectedRequest = new CreateOccurrenceRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                Occurrence          = new Occurrence(),
            };
            Occurrence expectedResponse = new Occurrence
            {
                OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"),
                NoteName       = "noteName1780787896",
                Remediation    = "remediation779381797",
            };

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public void CreateOccurrence()
        {
            Mock <Grafeas.GrafeasClient> mockGrpcClient  = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict);
            CreateOccurrenceRequest      expectedRequest = new CreateOccurrenceRequest
            {
                ParentAsProjectName = new ProjectName("[PROJECT]"),
                Occurrence          = new Occurrence(),
            };
            Occurrence expectedResponse = new Occurrence
            {
                OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"),
                ResourceUri    = "resourceUri-384040517",
                NoteName       = "noteName1780787896",
                Remediation    = "remediation779381797",
            };

            mockGrpcClient.Setup(x => x.CreateOccurrence(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            GrafeasClient client     = new GrafeasClientImpl(mockGrpcClient.Object, null);
            ProjectName   parent     = new ProjectName("[PROJECT]");
            Occurrence    occurrence = new Occurrence();
            Occurrence    response   = client.CreateOccurrence(parent, occurrence);

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