public async Task UpdateOccurrenceAsync() { Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict); UpdateOccurrenceRequest expectedRequest = new UpdateOccurrenceRequest { OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"), Occurrence = new Occurrence(), UpdateMask = new FieldMask(), }; Occurrence expectedResponse = new Occurrence { OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"), NoteName = "noteName1780787896", Remediation = "remediation779381797", }; mockGrpcClient.Setup(x => x.UpdateOccurrenceAsync(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 occurrence = new Occurrence(); FieldMask updateMask = new FieldMask(); Occurrence response = await client.UpdateOccurrenceAsync(name, occurrence, updateMask); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void UpdateOccurrence() { Mock <Grafeas.GrafeasClient> mockGrpcClient = new Mock <Grafeas.GrafeasClient>(MockBehavior.Strict); UpdateOccurrenceRequest expectedRequest = new UpdateOccurrenceRequest { OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"), Occurrence = new Occurrence(), UpdateMask = new FieldMask(), }; Occurrence expectedResponse = new Occurrence { OccurrenceName = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"), ResourceUri = "resourceUri-384040517", NoteName = "noteName1780787896", Remediation = "remediation779381797", }; mockGrpcClient.Setup(x => x.UpdateOccurrence(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); GrafeasClient client = new GrafeasClientImpl(mockGrpcClient.Object, null); OccurrenceName name = new OccurrenceName("[PROJECT]", "[OCCURRENCE]"); Occurrence occurrence = new Occurrence(); FieldMask updateMask = new FieldMask(); Occurrence response = client.UpdateOccurrence(name, occurrence, updateMask); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }