Пример #1
0
        public async Task TopViewsTest()
        {
            int messagesCount             = 10;
            MessagesController controller = GetMessagesController();

            await SendMessagesWithNumbers(controller, messagesCount);

            List <MessageResponse> messages = await controller.GetMessages(new GetMessageRequest { CurrentLocation = _zeroLocation });

            var topMessageToView    = messages[4].Id;
            var secondMessageToView = messages[7].Id;
            await controller.AddViewToMessage(new List <Guid> {
                topMessageToView
            });

            await controller.AddViewToMessage(new List <Guid> {
                topMessageToView
            });

            await controller.AddViewToMessage(new List <Guid> {
                topMessageToView, secondMessageToView
            });

            messages = await controller.GetTopViewedMessages(new SkipTakeMessagesRequest());

            Assert.AreEqual(1, messages.Count);
            Assert.AreEqual(messages[0].Id, topMessageToView);
        }
Пример #2
0
        public async Task ViewsTest()
        {
            int messagesCount             = 10;
            int messageToView             = 4;
            MessagesController controller = GetMessagesController();

            await SendMessagesWithNumbers(controller, messagesCount);

            List <MessageResponse> messages = await controller.GetMessages(new GetMessageRequest { CurrentLocation = _zeroLocation });

            await controller.AddViewToMessage(new List <Guid> {
                messages[messageToView].Id
            });

            messages = await controller.GetMessages(new GetMessageRequest { CurrentLocation = _zeroLocation });

            Assert.AreEqual(1, messages[messageToView].Views);
            Assert.AreEqual(0, messages[0].Views);
        }