示例#1
0
        public Task SendPushNotificationAsync(IPushState state, CancellationToken cancellationToken)
        {
            return(currentUserController.GetCurrentSessionTokenAsync(cancellationToken).OnSuccess(sessionTokenTask => {
                var command = new ParseCommand("push",
                                               method: "POST",
                                               sessionToken: sessionTokenTask.Result,
                                               data: ParsePushEncoder.Instance.Encode(state));

                return commandRunner.RunCommandAsync(command, cancellationToken: cancellationToken);
            }).Unwrap());
        }
示例#2
0
        public void SetUp()
        {
            ParseObject.RegisterSubclass <ParseUser>();
            ParseUser mockUser = ParseObject.Create <ParseUser>();

            _subscriptionFactory = new TestSubscriptionFactory();

            _currentUserController = Substitute.For <IParseCurrentUserController>();
            _currentUserController.GetAsync(Arg.Any <CancellationToken>()).Returns(Task.FromResult(mockUser));
            _currentUserController.GetCurrentSessionTokenAsync(Arg.Any <CancellationToken>()).Returns(Task.FromResult(mockUser.SessionToken));

            ParseCorePlugins.Instance = new ParseCorePlugins {
                CurrentUserController = _currentUserController
            };

            _parseLiveQueryClient = new ParseLiveQueryClient(new Uri("/", UriKind.Relative), (hostUri, callback) => {
                _webSocketClientCallback = callback;
                _webSocketClient         = Substitute.For <IWebSocketClient>();
                return(_webSocketClient);
            }, _subscriptionFactory, new ImmediateTaskQueue());

            Reconnect();
        }