Exemplo n.º 1
0
        private void ValidateReceivedEqualObjects <T>(Event objEvent, Func <T> objInitFunction, ErrorCallback <T> errorCallback = null)
            where T : ParseObject
        {
            T expectedObj = objInitFunction();

            expectedObj.ObjectId = "testId";
            ParseQuery <T> query = new ParseQuery <T>(expectedObj.ClassName);

            T actualObj = null;
            EventCallback <T>  eventCallback  = Substitute.For <EventCallback <T> >();
            EventsCallback <T> eventsCallback = Substitute.For <EventsCallback <T> >();

            eventCallback.Invoke(query, Arg.Do <T>(obj => actualObj = obj));

            Subscription <T> subscription = Subscribe(query).HandleEvent(objEvent, eventCallback).HandleEvents(eventsCallback);

            if (errorCallback != null)
            {
                subscription.HandleError(errorCallback);
            }
            _webSocketClientCallback.OnMessage(MockObjectEventMessage(objEvent, subscription.RequestId, expectedObj));

            eventCallback.Received().Invoke(query, actualObj);
            eventsCallback.Received().Invoke(query, objEvent, actualObj);
            Assert.AreEqual(expectedObj.ClassName, actualObj.ClassName);
            Assert.AreEqual(expectedObj.ObjectId, actualObj.ObjectId);
        }