public async Task TaskIsNotDisabledHandlesTaskDefinitionStateCountsProperly(int stateCount, bool throwsException)
        {
            const int taskDefinitionId     = 8;
            var       taskDefinitionStates = ImmutableList <TaskDefinitionState <int> > .Empty;

            for (int i = 0; i < stateCount; i++)
            {
                taskDefinitionStates = taskDefinitionStates.Add(new TaskDefinitionState <int>
                {
                    TaskDefinitionId = taskDefinitionId,
                });
            }
            var taskIsNotDisabled = TaskIsNotDisabled <int> .GetInstance(taskDefinitionStates.Transform <TaskDefinitionState <int>, ITaskDefinitionState <int> >());

            var taskDefinition = new TaskDefinition <int>
            {
                Id = taskDefinitionId
            } as ITaskDefinition <int>;

            if (throwsException)
            {
                await Assert.ThrowsAsync <TaskExecutionFaultException <int> >(async() => await taskIsNotDisabled.PassesAsync(taskDefinition));
            }
            else
            {
                await taskIsNotDisabled.PassesAsync(taskDefinition);
            }
        }
        public ImmutableList <TaskPrecondition <TIdentifier> > GetInBuiltPreconditions(ImmutableList <ITaskDefinition <TIdentifier> > taskDefinitions, ImmutableList <ITaskDefinitionState <TIdentifier> > taskDefinitionStates)
        {
            var result = ImmutableList <TaskPrecondition <TIdentifier> > .Empty;

            foreach (var singleTaskDefinition in taskDefinitions)
            {
                var taskSpecificPreconditions = ImmutableList <TaskPrecondition <TIdentifier> > .Empty
                                                .Add(TaskIsNotDisabled <TIdentifier> .GetInstance(taskDefinitionStates));

                foreach (var singleTaskPrecondition in taskSpecificPreconditions)
                {
                    singleTaskPrecondition.TaskName = singleTaskDefinition.Name;
                }

                result = result.AddRange(taskSpecificPreconditions);
            }

            return(result);
        }