public void removeMultiple(TodoItemsDeleted @event)
 {
     foreach (Guid guid in @event.aggregateIds)
     {
         this.RaiseEvent(new TodoItemDeleted(guid));
     }
 }
        /// <summary>
        /// Creates a random event. Needs to be updated every time new events get created!
        /// </summary>
        /// <returns>An event. </returns>
        private List<IEvent> getRandomEvent()
        {
            //returns less then specified number.
            int whichEvent = differentSeedRandom.Next(10);
            Debug.WriteLine("Case: " + whichEvent);
            switch (whichEvent)
            {
                    // List name changed
                case 0:
                    ListNameChanged listNameChanged = new ListNameChanged(getRandomString(nameLength));
                    return toList(listNameChanged);
                    // Todo item created
                case 1:
                    return toList(getRandomTodoItemCreated());
                    // Todo item description changed.
                case 2:
                    // Can only add events to items that exist.
                    if(getAvailableTodoItems().Count == 0)
                    {
                        break;
                    }
                    TodoItemDescriptionChanged todoItemDescriptionChanged = new TodoItemDescriptionChanged(getRandomTodoItemGuid(), getRandomString(descriptionLenght));
                    return toList(todoItemDescriptionChanged);
                    // Todo item name changed.
                case 3:
                    // Can only add events to items that exist.
                    if (getAvailableTodoItems().Count == 0)
                    {
                        break;
                    }
                    TodoItemNameChanged todoItemNameChanged = new TodoItemNameChanged(getRandomTodoItemGuid(), getRandomString(nameLength));
                    return toList(todoItemNameChanged);
                case 4:
                    // Need at least two items to change Priority. It's more of a swap priority.
                    if (getAvailableTodoItems().Count < 2)
                    {
                        break;
                    }
                    return getRandomTodoItemPriorityChanged();
                    // Todo item deleted.
                case 5:
                    if (getAvailableTodoItems().Count <= 1)
                    {
                        break;
                    }
                    return toList(getRandomTodoItemDeleted());
                    // Todo item Priority increased.
                case 6:
                    if (getAvailableTodoItems().Count == 0)
                    {
                        break;
                    }
                    return toList(new TodoItemPriorityIncreased(getRandomTodoItemGuid()));
                    // Todo item Priority decreased.
                case 7:
                    if (getAvailableTodoItems().Count == 0)
                    {
                        break;
                    }
                    TodoItemAggregate toDecrease = getAvailableTodoItems().ElementAt(
                                        differentSeedRandom.Next(getAvailableTodoItems().Count));

                    if (toDecrease.priority < 2)
                        break;
                    return toList(new TodoItemPriorityDecreased(toDecrease.id));
                    // Multiple delete of todo items.
                case 8:
                    if (getAvailableTodoItems().Count <=  3)
                        break;
                    // Build a list of items to remove. Random amount.
                    List<Guid> removedItems = new List<Guid>();
                    for (int i = 0; i < differentSeedRandom.Next(2, maxsimultaneousDelete + 1); i++)
                    {
                        removedItems.Add(getAvailableTodoItems().ElementAt(
                                        differentSeedRandom.Next(getAvailableTodoItems().Count)).id);
                    }
                    // Make sure there are no duplicates.
                    TodoItemsDeleted deletedItems = new TodoItemsDeleted(removedItems.Distinct().ToList());
                    return toList(deletedItems);
                case 9:
                    if (getAvailableTodoItems().Count == 0)
                        break;
                    return toList(getRandomTodoItemIndexChanged());

            }
            return getRandomEvent();
        }
 public IEvent transformEvent(TodoItemsDeleted toTransform, IEvent transformAgainst)
 {
     if (transformAgainst.GetType().Equals(typeof(TodoItemDeleted)))
     {
         //If this multi delete contains the delete on the other side, remove it from the deletes.
         if (toTransform.aggregateIds.Contains(((TodoItemDeleted)transformAgainst).aggregateId))
         {
             List<Guid> newAggregateList = toTransform.aggregateIds;
             newAggregateList.Remove(((TodoItemDeleted)transformAgainst).aggregateId);
             TodoItemsDeleted transformedEvent = new TodoItemsDeleted(newAggregateList);
             return transformedEvent;
         }
     }
     else if (transformAgainst.GetType().Equals(typeof(TodoItemsDeleted)))
     {
         // Figure out overlap and remove that.
         TodoItemsDeleted transformAgainstEvent = (TodoItemsDeleted)transformAgainst;
         List<Guid> newAggregateList = toTransform.aggregateIds;
         foreach (Guid toRemoveGuid in transformAgainstEvent.aggregateIds)
         {
             if (newAggregateList.Contains(toRemoveGuid))
                 newAggregateList.Remove(toRemoveGuid);
         }
         // If the list is now empty, remove the event.
         if (newAggregateList.Count == 0)
             return new Unused();
         // Else return a new event with the new list.
         return new TodoItemsDeleted(newAggregateList);
     }
     return toTransform;
 }