public void GetLifeEvent() { moq::Mock <LifeEventService.LifeEventServiceClient> mockGrpcClient = new moq::Mock <LifeEventService.LifeEventServiceClient>(moq::MockBehavior.Strict); GetLifeEventRequest request = new GetLifeEventRequest { ResourceNameAsLifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), }; gagvr::LifeEvent expectedResponse = new gagvr::LifeEvent { ResourceNameAsLifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), Id = -6774108720365892680L, LifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), ParentAsLifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), LaunchedToAll = true, Availabilities = { new gagvc::CriterionCategoryAvailability(), }, }; mockGrpcClient.Setup(x => x.GetLifeEvent(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); LifeEventServiceClient client = new LifeEventServiceClientImpl(mockGrpcClient.Object, null); gagvr::LifeEvent response = client.GetLifeEvent(request.ResourceName); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetLifeEventRequestObjectAsync() { moq::Mock <LifeEventService.LifeEventServiceClient> mockGrpcClient = new moq::Mock <LifeEventService.LifeEventServiceClient>(moq::MockBehavior.Strict); GetLifeEventRequest request = new GetLifeEventRequest { ResourceNameAsLifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), }; gagvr::LifeEvent expectedResponse = new gagvr::LifeEvent { ResourceNameAsLifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), Id = -6774108720365892680L, LifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), ParentAsLifeEventName = gagvr::LifeEventName.FromCustomerLifeEvent("[CUSTOMER_ID]", "[LIFE_EVENT_ID]"), LaunchedToAll = true, Availabilities = { new gagvc::CriterionCategoryAvailability(), }, }; mockGrpcClient.Setup(x => x.GetLifeEventAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <gagvr::LifeEvent>(stt::Task.FromResult(expectedResponse), null, null, null, null)); LifeEventServiceClient client = new LifeEventServiceClientImpl(mockGrpcClient.Object, null); gagvr::LifeEvent responseCallSettings = await client.GetLifeEventAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); gagvr::LifeEvent responseCancellationToken = await client.GetLifeEventAsync(request, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }