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, 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; }
protected override IEnumerable <WhenStep> When() { ProjectionManagementMessage.Command.Post message = new ProjectionManagementMessage.Command.Post( Envelope, ProjectionMode.OneTime, _projectionName, ProjectionManagementMessage.RunAs.System, typeof(FakeForeachStreamProjection), "", true, false, false, false); _managedProjection.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); _managedProjection.Handle( new CoreProjectionStatusMessage.Prepared( _coreProjectionId, projectionSourceDefinition)); _originalPersistedStateEventId = _consumer.HandledMessages.OfType <ClientMessage.WriteEvents>() .Where(x => x.EventStreamId == _projectionDefinitionStreamId).First().Events[0].EventId; CompleteWriteWithResult(_failureCondition); _consumer.HandledMessages.Clear(); yield break; }
protected override void Given() { _timeProvider = new FakeTimeProvider(); _mp = CreateManagedProjection(); _mp.InitializeNew( new ManagedProjection.PersistedState { Enabled = false, HandlerType = "JS", Query = "fromAll().when({});", Mode = ProjectionMode.Continuous, EmitEnabled = true, CheckpointsDisabled = false, Epoch = -1, Version = -1, RunAs = SerializedRunAs.SerializePrincipal(ProjectionManagementMessage.RunAs.Anonymous), }, null); _mp.Handle(new CoreProjectionStatusMessage.Prepared(_projectionId, new ProjectionSourceDefinition())); OneWriteCompletes(); _consumer.HandledMessages.Clear(); _mp.Handle(new CoreProjectionStatusMessage.Faulted( _projectionId, "test")); _updateConfig = CreateConfig(); try { _mp.Handle(_updateConfig); } catch (Exception ex) { _thrownException = ex; } }
protected ProjectionManagementMessage.ProjectionConfig GetProjectionConfig(ManagedProjection mp) { ProjectionManagementMessage.ProjectionConfig getConfigResult = null; mp.Handle(new ProjectionManagementMessage.Command.GetConfig( new CallbackEnvelope(m => getConfigResult = (ProjectionManagementMessage.ProjectionConfig)m), "name", SerializedRunAs.SerializePrincipal(ProjectionManagementMessage.RunAs.Anonymous))); return(getConfigResult); }
protected override void Given() { var persistedState = new ManagedProjection.PersistedState { Enabled = true, HandlerType = "JS", Query = @"log(1);", Mode = ProjectionMode.Continuous, EmitEnabled = true, CheckpointsDisabled = true, Epoch = -1, Version = -1, RunAs = SerializedRunAs.SerializePrincipal(ProjectionManagementMessage.RunAs.Anonymous), ProjectionSubsystemVersion = 4 }; ExistingEvent(ProjectionNamesBuilder.ProjectionsStreamPrefix + _projectionName, ProjectionEventTypes.ProjectionUpdated, "", persistedState.ToJson()); _timeProvider = new FakeTimeProvider(); _mp = new ManagedProjection( Guid.NewGuid(), Guid.NewGuid(), 1, "name", true, null, _streamDispatcher, _writeDispatcher, _readDispatcher, _bus, _timeProvider, new RequestResponseDispatcher <CoreProjectionManagementMessage.GetState, CoreProjectionStatusMessage.StateReport>( _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus)), new RequestResponseDispatcher <CoreProjectionManagementMessage.GetResult, CoreProjectionStatusMessage.ResultReport>( _bus, v => v.CorrelationId, v => v.CorrelationId, new PublishEnvelope(_bus)), _ioDispatcher, TimeSpan.FromMinutes(Opts.ProjectionsQueryExpiryDefault)); }
public void null_query_throws_argument_null_exception() { ProjectionManagementMessage.Command.Post message = new ProjectionManagementMessage.Command.Post( new NoopEnvelope(), ProjectionMode.OneTime, "name", ProjectionManagementMessage.RunAs.Anonymous, "JS", query: null, 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); }
public void empty_handler_type_throws_argument_null_exception() { Assert.Throws <ArgumentException>(() => { ProjectionManagementMessage.Command.Post message = new ProjectionManagementMessage.Command.Post( new NoopEnvelope(), ProjectionMode.OneTime, "name", ProjectionManagementMessage.RunAs.Anonymous, "", @"log(1);", enabled: true, checkpointsEnabled: false, emitEnabled: false, trackEmittedStreams: 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); }); }