public async void RemoveAllOlderThanShouldHaveOneRecord()
        {
            await MessageUtils.RemoveAllOlderThan(Conf.MAX_MESSAGE_RETENTION_TIME_IN_MINUTES);

            var messagesAfterRemoval = await MessageUtils.GetMessages();

            messagesAfterRemoval.Should().HaveCount(1);
        }
예제 #2
0
        private async void Init()
        {
            MessagesViewModel.SubscribeMessages(this, ClearAndAddNewMessages);

            _messagesList        = FindViewById <ListView>(Resource.Id.messages_list);
            _noItemsTextView     = FindViewById <TextView>(Resource.Id.no_items_description);
            _lastUpdatedTextView = FindViewById <TextView>(Resource.Id.last_updated);

            _messagesList.Divider       = null;
            _messagesList.DividerHeight = 0;


            TextView title = FindViewById <TextView>(Resource.Id.messages_page_title);

            title.Text = MessagesViewModel.MESSAGES_HEADER;
            title.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());

            string headerText     = MessagesViewModel.MESSAGES_NO_ITEMS_TITLE;
            int    unreadMessages = (await MessageUtils.GetAllUnreadMessages()).Count;
            int    messages       = (await MessageUtils.GetMessages()).Count;

            if (unreadMessages > 0)
            {
                headerText = MessagesViewModel.MESSAGES_NEW_MESSAGES_HEADER;
            }
            else if (messages > 0)
            {
                headerText = MessagesViewModel.MESSAGES_NO_NEW_MESSAGES_HEADER;
            }

            TextView subheader = FindViewById <TextView>(Resource.Id.messages_page_sub_header);

            subheader.Text = headerText;
            subheader.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());

            string lastUpdatedString = MessagesViewModel.LastUpdateString;

            if (lastUpdatedString == "")
            {
                _lastUpdatedTextView.Visibility = ViewStates.Gone;
            }
            else
            {
                _lastUpdatedTextView.Visibility = ViewStates.Visible;
                _lastUpdatedTextView.Text       = MessagesViewModel.LastUpdateString;
            }

            _noItemsTextView.Text = MessagesViewModel.MESSAGES_NO_ITEMS_DESCRIPTION;

            _closeButton        = FindViewById <ImageView>(Resource.Id.arrow_back);
            _closeButton.Click += new StressUtils.SingleClick(OnCloseBtnClicked).Run;
            _closeButton.ContentDescription = MessagesViewModel.MESSAGES_ACCESSIBILITY_CLOSE_BUTTON;

            _adapterMessages                  = new MessagesAdapter(this, new MessageItemViewModel[0]);
            _messagesList.Adapter             = _adapterMessages;
            _messagesList.OnItemClickListener = new ItemClickListener(_adapterMessages);
            ShowList(false);
        }
        public async void GetAllUnreadShouldReturnTwoRecords()
        {
            var models = MessageUtils.ToMessageItemViewModelList(await MessageUtils.GetMessages());

            MessageUtils.MarkAsRead(models[1], true);

            var messagesAfterMark = await MessageUtils.GetAllUnreadMessages();

            messagesAfterMark.Should().HaveCount(2);

            messagesAfterMark.All(message => message.IsRead == false).Should().BeTrue();
        }
        public async void MarkAsReadShouldMarkRecords()
        {
            var models = MessageUtils.ToMessageItemViewModelList(await MessageUtils.GetMessages());

            MessageUtils.MarkAsRead(models[1], true);

            var messagesAfterMark = await MessageUtils.GetMessages();

            messagesAfterMark.Should().HaveCount(3);

            messagesAfterMark[0].IsRead.Should().BeFalse();
            messagesAfterMark[1].IsRead.Should().BeTrue();
            messagesAfterMark[2].IsRead.Should().BeFalse();
        }
        public async void RemoveShouldHaveTwoRecords()
        {
            var models = await MessageUtils.GetMessages();

            await MessageUtils.RemoveMessages(models.GetRange(0, 1));

            var messagesAfterRemoval = await MessageUtils.GetMessages();

            messagesAfterRemoval.Should().HaveCount(2);

            messagesAfterRemoval.Any(model => model.ID == models[0].ID).Should().BeFalse();
            messagesAfterRemoval.Any(model => model.ID == models[1].ID).Should().BeTrue();
            messagesAfterRemoval.Any(model => model.ID == models[2].ID).Should().BeTrue();
        }
예제 #6
0
        async Task NewMessagesFetched()
        {
            List <MessageItemViewModel> orderedMessages =
                MessageUtils.ToMessageItemViewModelList((await MessageUtils.GetMessages())
                                                        .OrderByDescending(message => message.TimeStamp)
                                                        .ToList());

            if (orderedMessages.Any())
            {
                _latestMessageDateTime = orderedMessages[0].TimeStamp;
            }

            List <MessageSQLiteModel> unreadMessagesResult = await MessageUtils.GetAllUnreadMessages();

            ShowNewMessageIcon = unreadMessagesResult.Any();

            NewMessagesIconVisibilityChanged?.Invoke(this, null);
        }
예제 #7
0
        private async void SetStyling()
        {
            StyleUtil.InitLabelWithSpacing(Label, StyleUtil.FontType.FontBold, MESSAGES_HEADER, 0.8, 22, 34);
            StyleUtil.InitLabelWithSpacing(LabelLastUpdate, StyleUtil.FontType.FontRegular, LastUpdateString, 1.14, 15, 17, UITextAlignment.Left);
            int    unreadMessages = (await MessageUtils.GetAllUnreadMessages()).Count;
            int    messages       = (await MessageUtils.GetMessages()).Count;
            string headerText     = MESSAGES_NO_ITEMS_TITLE;

            if (unreadMessages > 0)
            {
                headerText = MESSAGES_NEW_MESSAGES_HEADER;
            }
            else if (messages > 0)
            {
                headerText = MESSAGES_NO_NEW_MESSAGES_HEADER;
            }
            StyleUtil.InitLabelWithSpacing(NoItemsLabel1, StyleUtil.FontType.FontBold, headerText, 1, 32, 34);
            StyleUtil.InitLabelWithSpacing(NoItemsLabel2, StyleUtil.FontType.FontRegular, MESSAGES_NO_ITEMS_DESCRIPTION, 1.25, 18, 20, UITextAlignment.Left);
            BackButton.AccessibilityLabel = SettingsViewModel.SETTINGS_CHILD_PAGE_ACCESSIBILITY_BACK_BUTTON;
        }
예제 #8
0
 public static async Task <List <MessageItemViewModel> > GetMessages()
 {
     return(MessageUtils.ToMessageItemViewModelList(await MessageUtils.GetMessages()));
 }
 public async void RemoveAllShouldHaveZeroRecords()
 {
     MessageUtils.RemoveAll();
     (await MessageUtils.GetMessages()).Should().HaveCount(0);
 }
 public async void GetMessagesShouldReturnThreeRecords()
 {
     (await MessageUtils.GetMessages()).Should().HaveCount(3);
 }