Пример #1
0
 protected override void Given()
 {
     _timeProvider = new FakeTimeProvider();
     _mp           = new ManagedProjection(
         _bus, Guid.NewGuid(), 1, "name", true, null, _writeDispatcher, _readDispatcher, _bus, _bus, _handlerFactory,
         _timeProvider);
 }
Пример #2
0
 protected override void Given()
 {
     _projectionName = "projectionName";
     _projectionDefinitionStreamId = ProjectionNamesBuilder.ProjectionsStreamPrefix + _projectionName;
     _coreProjectionId             = Guid.NewGuid();
     _timeProvider      = new FakeTimeProvider();
     _managedProjection = new ManagedProjection(
         Guid.NewGuid(),
         Guid.NewGuid(),
         1,
         _projectionName,
         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));
 }
 protected override void Given()
 {
     _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);
 }
        protected override IEnumerable <WhenStep> When()
        {
            ProjectionManagementMessage.Post message = new ProjectionManagementMessage.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 ? ManagedProjection.SerializePrincipal(message.RunAs) : null,
            });

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

            _mp.Handle(
                new CoreProjectionManagementMessage.Prepared(
                    _coreProjectionId, projectionSourceDefinition, null));
            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()
        {
            _timeProvider = new FakeTimeProvider();
            _mp           = CreateManagedProjection();

            _mp.InitializeNew(
                _persistedState,
                null);
            _mp.Handle(new CoreProjectionStatusMessage.Prepared(_projectionId, new ProjectionSourceDefinition()));

            // Complete write of persisted state to start projection
            OneWriteCompletes();
            _config = GetProjectionConfig(_mp);
        }
Пример #8
0
 public void null_query_throws_argument_null_exception()
 {
     ProjectionManagementMessage.Post message = new ProjectionManagementMessage.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 ? ManagedProjection.SerializePrincipal(message.RunAs) : null,
     });
 }
        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));
        }
        protected override void Given()
        {
            _timeProvider = new FakeTimeProvider();
            _mp           = CreateManagedProjection();

            _mp.InitializeNew(
                _persistedState,
                null);
            _mp.Handle(new CoreProjectionStatusMessage.Prepared(_projectionId, new ProjectionSourceDefinition()));

            // Complete write of persisted state to start projection
            OneWriteCompletes();

            try {
                _mp.Handle(CreateConfig());
            } catch (InvalidOperationException ex) {
                _thrownException = ex;
            }
        }
Пример #11
0
 public FaultedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #12
0
 public CompletedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #13
0
 public FaultedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #14
0
 public LoadingStateState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
 protected ManagedProjectionStateBase(ManagedProjection managedProjection)
 {
     _managedProjection = managedProjection;
 }
Пример #16
0
 public DeletingState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
     managedProjection.DeleteProjectionStreams();
 }
Пример #17
0
 public StartingState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #18
0
 public CompletedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #19
0
 public RunningState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
 public CreatingLoadingLoadedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #21
0
 protected override void Given()
 {
     _mp = new ManagedProjection(
         Guid.NewGuid(), "name", null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }
Пример #22
0
 public CreatingLoadingLoadedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #23
0
 public PreparedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #24
0
 public PreparingState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #25
0
 public AbortedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
 public void empty_name_throws_argument_exception2()
 {
     var mp = new ManagedProjection(_bus,
                                    Guid.NewGuid(), "", null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }
Пример #27
0
 public DeletingState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
     managedProjection.DeleteProjectionStreams();
 }
Пример #28
0
 public StoppedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #29
0
 public StoppedState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
Пример #30
0
 protected ManagedProjectionStateBase(ManagedProjection managedProjection)
 {
     _managedProjection = managedProjection;
 }
Пример #31
0
 public AbortingState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
 public void empty_guid_throws_invali_argument_exception2()
 {
     var mp = new ManagedProjection(_bus,
                                    Guid.Empty, "name", null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }
Пример #33
0
 public RunningState(ManagedProjection managedProjection)
     : base(managedProjection)
 {
 }
 public void null_name_throws_argument_null_exception()
 {
     var mp = new ManagedProjection(
         Guid.NewGuid(), null, null, _writeDispatcher, _readDispatcher, _bus, _handlerFactory);
 }