protected override IEnumerable<WhenStep> When()
        {
            ProjectionManagementMessage.Command.Post message = new ProjectionManagementMessage.Command.Post(
                Envelope, ProjectionMode.Transient, _projectionName, ProjectionManagementMessage.RunAs.System,
                typeof(FakeForeachStreamProjection), "", true, false, false);
            _mp.InitializeNew(
                new ManagedProjection.PersistedState
                {
                    Enabled = message.Enabled,
                    HandlerType = message.HandlerType,
                    Query = message.Query,
                    Mode = message.Mode,
                    EmitEnabled = message.EmitEnabled,
                    CheckpointsDisabled = !message.CheckpointsEnabled,
                    Epoch = -1,
                    Version = -1,
                    RunAs = message.EnableRunAs ? SerializedRunAs.SerializePrincipal(message.RunAs) : null,
                },
                null);

            var sourceDefinition = new FakeForeachStreamProjection("", Console.WriteLine).GetSourceDefinition();
            var projectionSourceDefinition = ProjectionSourceDefinition.From(sourceDefinition);

            _mp.Handle(
                new CoreProjectionStatusMessage.Prepared(
                    _coreProjectionId, projectionSourceDefinition));
            yield break;
        }
 public void empty_handler_type_throws_argument_null_exception()
 {
     ProjectionManagementMessage.Command.Post message = new ProjectionManagementMessage.Command.Post(
         new NoopEnvelope(), ProjectionMode.OneTime, "name", ProjectionManagementMessage.RunAs.Anonymous, "",
         @"log(1);", enabled: true, checkpointsEnabled: false, emitEnabled: false);
     _mp.InitializeNew(
         new ManagedProjection.PersistedState
         {
             Enabled = message.Enabled,
             HandlerType = message.HandlerType,
             Query = message.Query,
             Mode = message.Mode,
             EmitEnabled = message.EmitEnabled,
             CheckpointsDisabled = !message.CheckpointsEnabled,
             Epoch = -1,
             Version = -1,
             RunAs = message.EnableRunAs ? SerializedRunAs.SerializePrincipal(message.RunAs) : null,
         },
         null);
 }