Exemple #1
0
        public async Task GiveValidConversationId_ShouldHideConversationToLoginUser()
        {
            // mock login user
            _currentUserServiceMock.Setup(m => m.UserId)
            .Returns(userId1.ToString());

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

            var command = new HideConversationCommand
            {
                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.isHidden.ShouldBeTrue();
                }
            }
        }
Exemple #2
0
        public void GiveInvalidConversationId_ShouldRaiseNotFound()
        {
            // mock login user
            _currentUserServiceMock.Setup(m => m.UserId)
            .Returns(userId1.ToString());

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

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

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