Exemplo n.º 1
0
        public async Task GiveValidConversationId_ShouldReadConversationToLoginUser()
        {
            // mock login user
            _currentUserServiceMock.Setup(m => m.UserId)
            .Returns(userId1.ToString());
            var oldEntity = _context.Conversations.Find(conversationId);

            foreach (var member in oldEntity.Members)
            {
                if (member.UserOid == userId1.ToString())
                {
                    oldLastSeenTime = member.LastSeenTime;
                }
            }

            var sut = new ReadConversationCommandHandler(_context, _currentUserServiceMock.Object);

            var command = new ReadConversationCommand
            {
                ConversationId = conversationId.ToString()
            };

            await sut.Handle(command, CancellationToken.None);

            var entity = _context.Conversations.Find(conversationId);

            foreach (var member in entity.Members)
            {
                if (member.UserOid == userId1.ToString())
                {
                    member.LastSeenTime.ShouldBeGreaterThan(oldLastSeenTime);
                }
            }
        }
Exemplo n.º 2
0
        public void GiveInvalidConversationId_ShouldRaiseNotFound()
        {
            // mock login user
            _currentUserServiceMock.Setup(m => m.UserId)
            .Returns(userId1.ToString());

            var sut = new ReadConversationCommandHandler(_context, _currentUserServiceMock.Object);

            var command = new ReadConversationCommand
            {
                ConversationId = invalidConversationId.ToString()
            };

            _ = Should.ThrowAsync <NotFoundException>(() =>
                                                      sut.Handle(command, CancellationToken.None));
        }