public void Simple()
        {
            var service = new GetRegistrationService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };


            var helper = new AsyncTestHelper <GetRegistrationResponse>();
            var getRegistrationRequest = new GetRegistrationRequest
            {
                DeviceToken = RemoteSettings.AppleDeviceId
            };

            service.Execute(getRegistrationRequest, helper.Callback, helper.HandleException);
            helper.Wait();

            var registration = helper.Response;

            Debug.WriteLine(registration.Alias);
            Debug.WriteLine(registration.Badge);
            Debug.WriteLine(registration.QuietTime.Start);
            Debug.WriteLine(registration.QuietTime.End);
            Debug.WriteLine(string.Join(" ", registration.Tags));
            Debug.WriteLine(registration.TimeZone);
        }
Exemplo n.º 2
0
        public void Simple()
        {
            var service = new GetRegistrationService
            {
                RequestBuilder = ServerRequestBuilder.Instance
            };
            var request = new GetRegistrationRequest {
                PushId = "AndroidPushId"
            };

            service.Execute(request, Callback, ExceptionHandler.Handle);
        }
        public void Tags()
        {
            var service = new GetRegistrationService
            {
                RequestBuilder = ServerRequestBuilder.Instance
            };
            var request = new GetRegistrationRequest
            {
                DeviceToken = "ApplePushId"
            };

            service.Execute(request, Callback, ExceptionHandler.Handle);
        }
        public void Simple()
        {
            var service = new GetRegistrationService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };
            var helper  = new AsyncTestHelper <GetRegistrationResponse>();
            var request = new GetRegistrationRequest
            {
                PushId = RemoteSettings.AndroidPushId
            };

            service.Execute(request, helper.Callback, helper.HandleException);
            helper.Wait();
        }
        public async stt::Task GetRegistrationResourceNamesAsync()
        {
            moq::Mock <Domains.DomainsClient> mockGrpcClient = new moq::Mock <Domains.DomainsClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetRegistrationRequest request = new GetRegistrationRequest
            {
                RegistrationName = RegistrationName.FromProjectLocationRegistration("[PROJECT]", "[LOCATION]", "[REGISTRATION]"),
            };
            Registration expectedResponse = new Registration
            {
                RegistrationName = RegistrationName.FromProjectLocationRegistration("[PROJECT]", "[LOCATION]", "[REGISTRATION]"),
                DomainName       = "domain_nameea17a44f",
                CreateTime       = new wkt::Timestamp(),
                ExpireTime       = new wkt::Timestamp(),
                State            = Registration.Types.State.Unspecified,
                Issues           =
                {
                    Registration.Types.Issue.UnverifiedEmail,
                },
                Labels =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                ManagementSettings     = new ManagementSettings(),
                DnsSettings            = new DnsSettings(),
                ContactSettings        = new ContactSettings(),
                PendingContactSettings = new ContactSettings(),
                SupportedPrivacy       =
                {
                    ContactPrivacy.PublicContactData,
                },
            };

            mockGrpcClient.Setup(x => x.GetRegistrationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Registration>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            DomainsClient client = new DomainsClientImpl(mockGrpcClient.Object, null);
            Registration  responseCallSettings = await client.GetRegistrationAsync(request.RegistrationName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Registration responseCancellationToken = await client.GetRegistrationAsync(request.RegistrationName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public void NotFound()
        {
            var service = new GetRegistrationService
            {
                RequestBuilder = RequestBuilderHelper.Build()
            };


            var helper = new AsyncTestHelper <GetRegistrationResponse>();
            var getRegistrationRequest = new GetRegistrationRequest
            {
                DeviceToken = "foo"
            };

            service.Execute(getRegistrationRequest, helper.Callback, helper.HandleException);
            helper.Wait();
            Assert.IsNull(helper.Response);
        }