Esempio n. 1
0
        public async Task Handle_GivenConversationIdAndMemberListValid_ShouldUpdateConversation()
        {
            ////Arrange
            var sut = new UpdateConversationNameCommandHandler(_context, _mapper);

            var command = new UpdateConversationNameCommand
            {
                Id      = validConversationId,
                Name    = "valid group name",
                Members = new List <UserModel>()
                {
                    new UserModel()
                    {
                        UserId      = validUserId1,
                        DisplayName = "test"
                    }
                }
            };

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

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

            entity.ShouldNotBeNull();
            entity.Name.ShouldBe("valid group name");
            entity.Members.Count.ShouldBe(1);
        }
Esempio n. 2
0
        public async Task Handle_GivenConversationIdInvalid_ShouldRaiseNotFoundException()
        {
            ////Arrange
            var sut = new UpdateConversationNameCommandHandler(_context, _mapper);

            var command = new UpdateConversationNameCommand
            {
                Id   = Guid.NewGuid(),
                Name = "valid group name"
            };

            //// Act
            await Assert.ThrowsAsync <NotFoundException>(() => sut.Handle(command, CancellationToken.None));
        }
Esempio n. 3
0
        public async Task Handle_GivenConversationIdValid_ShouldUpdateConversation()
        {
            ////Arrange
            var sut = new UpdateConversationNameCommandHandler(_context, _mapper);

            var command = new UpdateConversationNameCommand
            {
                Id   = validConversationId,
                Name = "valid group name"
            };

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

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

            entity.ShouldNotBeNull();
            entity.Name.ShouldBe("valid group name");
        }