public void HandlePushNotificationExistingConversationTest()
        {
            List<List<ConversationModel>>  conversations = new List<List<ConversationModel>>();
            List<UserModel>  owners = new List<UserModel>();
            this.LoadConversations(conversations, owners);

            for (int i = 0; i < conversations.Count; i++)
            {
                if (conversations[i].Count == 0)
                {
                    return;
                }

                MockServiceProxy serviceProxy = new MockServiceProxy() { Conversations = conversations[i] };
                MockUserSettings userSettings = new MockUserSettings();
                MockDataContextWrapper dataContextWrapper = new MockDataContextWrapper(new MockDatabase() { Conversations = conversations[i] });
                userSettings.Save(owners[i]);

                using (AllConversationsViewModel allConversations = new AllConversationsViewModel(serviceProxy, userSettings, dataContextWrapper))
                {
                    allConversations.LoadInitialConversations();

                    NotifyCollectionChangedTester<ConversationModel> collectionChangedTester = new NotifyCollectionChangedTester<ConversationModel>(allConversations.Conversations);
                    long existingConversationId = conversations[i].Count > 0 ? conversations[i][0].ConversationId : long.MaxValue;
                    int existingConversationUserId = -1;

                    foreach (UserModel user in conversations[i][0].ConversationParticipants)
                    {
                        if (user.Id != owners[i].Id)
                        {
                            existingConversationUserId = user.Id;
                        }
                    }

                    foreach (ConversationModel conversation in conversations[i])
                    {
                        foreach (UserModel user in conversation.ConversationParticipants)
                        {
                            if (user.Id != owners[i].Id)
                            {
                                Assert.AreEqual(conversation, allConversations.GetConversationFromConversationId(conversation.ConversationId), "Conversation cannot be retrieved by guid");
                                Assert.AreEqual(conversation, allConversations.GetConversation(user.Id), "Conversation cannot be retrieved by recipient");
                            }
                        }
                    }

                    PushNotificationEvent pushEvent = new PushNotificationEvent(this, (long)2000, existingConversationId, "test", DateTime.Now.Ticks, "HandlePushNotificationExistingConversationTest" + i.ToString(), existingConversationUserId);
                    Messenger.Default.Send<PushNotificationEvent>(pushEvent);

                    Assert.AreEqual(collectionChangedTester.Count, 1, "Push notification was not handled. The new conversation was not added to the collection");
                }
            }
        }
        public void HandlePushNotificationNewConversationTest()
        {
            List<List<ConversationModel>> conversations = new List<List<ConversationModel>>();
            List<UserModel> owners = new List<UserModel>();
            this.LoadConversations(conversations, owners);

            for (int i = 0; i < conversations.Count; i++)
            {
                MockServiceProxy serviceProxy = new MockServiceProxy() { Conversations = conversations[i] };
                MockUserSettings userSettings = new MockUserSettings();
                MockDataContextWrapper dataContextWrapper = new MockDataContextWrapper(new MockDatabase() { Conversations = conversations[i] });
                userSettings.Save(owners[i]);

                using (AllConversationsViewModel allConversations = new AllConversationsViewModel(serviceProxy, userSettings, dataContextWrapper))
                {
                    allConversations.LoadInitialConversations();

                    NotifyCollectionChangedTester<ConversationModel> collectionChangedTester = new NotifyCollectionChangedTester<ConversationModel>(allConversations.Conversations);
                    int newUserId = 5000;
                    long newConversationId = long.MaxValue;
                    Messenger.Default.Send<PushNotificationEvent>(new PushNotificationEvent(this, (long)2000, newConversationId, "test", DateTime.Now.Ticks, "HandlePushNotificationNewConversationTest" + i.ToString(), newUserId));

                    // We should be able to retrieve the new conversation by recipient and by conversation id
                    Assert.AreNotEqual(null, allConversations.GetConversation(newUserId));
                    Assert.AreNotEqual(null, allConversations.GetConversationFromConversationId(newConversationId));

                    // There should be one collection changed event
                    Assert.AreEqual(collectionChangedTester.Count, 1, "Push notification was not handled. The new conversation was not added to the collection");
                }
            }
        }