示例#1
0
        public void Should_Throw_Exception_On_Moving_Column_With_Old_Timestamp()
        {
            // Given
            var board    = context.KanbanBoards.Include(x => x.Columns).First();
            var user     = context.AppUsers.FirstOrDefault();
            var handler  = new MoveColumn(repository, CreateAccessServiceMock().Object);
            var column   = board.Columns.OrderBy(x => x.Index).First();
            var newIndex = 1;

            // When/Then
            Assert.CatchAsync <ConflictException>(
                async() => await handler.HandleAsync(
                    new MoveColumn.Command(user.ID, board.ID, column.ID, newIndex, DateTime.Now)));
        }
示例#2
0
        public void Should_Throw_Exception_On_Moving_Column_To_Other_Board()
        {
            // Given
            var boards     = context.KanbanBoards.Include(x => x.Columns);
            var firstBoard = boards.First();
            var lastBoard  = boards.Last();
            var user       = context.AppUsers.FirstOrDefault();
            var handler    = new MoveColumn(repository, CreateAccessServiceMock().Object);
            var column     = firstBoard.Columns.OrderBy(x => x.Index).First();
            var newIndex   = 1;

            // When/Then
            Assert.CatchAsync <ArgumentException>(
                async() => await handler.HandleAsync(
                    new MoveColumn.Command(user.ID, lastBoard.ID, column.ID, newIndex, lastBoard.Timestamp)));
        }
示例#3
0
        public void Should_Move_Column_To_New_Index()
        {
            // Given
            var board       = context.KanbanBoards.Include(x => x.Columns).FirstOrDefault();
            var user        = context.AppUsers.FirstOrDefault();
            var handler     = new MoveColumn(repository, CreateAccessServiceMock().Object);
            var firstColumn = board.Columns.OrderBy(x => x.Index).First();
            var newIndex    = 1;

            // When
            handler.HandleAsync(
                new MoveColumn.Command(user.ID, board.ID, firstColumn.ID, newIndex, board.Timestamp)).Wait();

            // Then
            var newIndexes = board.Columns.OrderBy(x => x.Index).Select(x => x.Index);

            Assert.AreEqual(newIndex, firstColumn.Index);
            CollectionAssert.AreEqual(new[] { 0, 1, 2 }, newIndexes);
        }