Exemplo n.º 1
0
            public void ShouldCloseSubscriptions()
            {
                ParseQuery <ParseObject>          query               = new ParseQuery <ParseObject>("test");
                EventCallback <ParseObject>       eventCallback       = Substitute.For <EventCallback <ParseObject> >();
                UnsubscribeCallback <ParseObject> unsubscribeCallback = Substitute.For <UnsubscribeCallback <ParseObject> >();

                Subscription <ParseObject> subscription = Subscribe(query)
                                                          .HandleEvent(Event.Create, eventCallback)
                                                          .HandleUnsubscribe(unsubscribeCallback);

                _parseLiveQueryClient.Unsubscribe(query);

                _webSocketClient.Received().Send(Arg.Any <string>());

                _webSocketClientCallback.OnMessage(MockUnsubscribedMessage(subscription.RequestId));

                unsubscribeCallback.Received().Invoke(query);

                ParseObject parseObject = new ParseObject("Test")
                {
                    ObjectId = "testId"
                };

                _webSocketClientCallback.OnMessage(MockObjectEventMessage(Event.Create, subscription.RequestId, parseObject));

                eventCallback.DidNotReceive().Invoke(query, Arg.Any <ParseObject>());
            }