public async stt::Task PreviewRealmUpdateRequestObjectAsync() { moq::Mock <RealmsService.RealmsServiceClient> mockGrpcClient = new moq::Mock <RealmsService.RealmsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); PreviewRealmUpdateRequest request = new PreviewRealmUpdateRequest { Realm = new Realm(), UpdateMask = new wkt::FieldMask(), PreviewTime = new wkt::Timestamp(), }; PreviewRealmUpdateResponse expectedResponse = new PreviewRealmUpdateResponse { Etag = "etage8ad7218", TargetState = new TargetState(), }; mockGrpcClient.Setup(x => x.PreviewRealmUpdateAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <PreviewRealmUpdateResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); RealmsServiceClient client = new RealmsServiceClientImpl(mockGrpcClient.Object, null); PreviewRealmUpdateResponse responseCallSettings = await client.PreviewRealmUpdateAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); PreviewRealmUpdateResponse responseCancellationToken = await client.PreviewRealmUpdateAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void GetRealmRequestObject() { moq::Mock <RealmsService.RealmsServiceClient> mockGrpcClient = new moq::Mock <RealmsService.RealmsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetRealmRequest request = new GetRealmRequest { RealmName = RealmName.FromProjectLocationRealm("[PROJECT]", "[LOCATION]", "[REALM]"), }; Realm expectedResponse = new Realm { RealmName = RealmName.FromProjectLocationRealm("[PROJECT]", "[LOCATION]", "[REALM]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, TimeZone = "time_zone73f23b20", Etag = "etage8ad7218", Description = "description2cf9da67", }; mockGrpcClient.Setup(x => x.GetRealm(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RealmsServiceClient client = new RealmsServiceClientImpl(mockGrpcClient.Object, null); Realm response = client.GetRealm(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetRealmRequestObjectAsync() { moq::Mock <RealmsService.RealmsServiceClient> mockGrpcClient = new moq::Mock <RealmsService.RealmsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetRealmRequest request = new GetRealmRequest { RealmName = RealmName.FromProjectLocationRealm("[PROJECT]", "[LOCATION]", "[REALM]"), }; Realm expectedResponse = new Realm { RealmName = RealmName.FromProjectLocationRealm("[PROJECT]", "[LOCATION]", "[REALM]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, TimeZone = "time_zone73f23b20", Etag = "etage8ad7218", Description = "description2cf9da67", }; mockGrpcClient.Setup(x => x.GetRealmAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Realm>(stt::Task.FromResult(expectedResponse), null, null, null, null)); RealmsServiceClient client = new RealmsServiceClientImpl(mockGrpcClient.Object, null); Realm responseCallSettings = await client.GetRealmAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Realm responseCancellationToken = await client.GetRealmAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void PreviewRealmUpdateRequestObject() { moq::Mock <RealmsService.RealmsServiceClient> mockGrpcClient = new moq::Mock <RealmsService.RealmsServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); PreviewRealmUpdateRequest request = new PreviewRealmUpdateRequest { Realm = new Realm(), UpdateMask = new wkt::FieldMask(), PreviewTime = new wkt::Timestamp(), }; PreviewRealmUpdateResponse expectedResponse = new PreviewRealmUpdateResponse { Etag = "etage8ad7218", TargetState = new TargetState(), }; mockGrpcClient.Setup(x => x.PreviewRealmUpdate(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RealmsServiceClient client = new RealmsServiceClientImpl(mockGrpcClient.Object, null); PreviewRealmUpdateResponse response = client.PreviewRealmUpdate(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }