コード例 #1
0
        public async Task Then_the_projection_processed_the_next_events_as_subscription()
        {
            ProjectionManager.Start(_projection);

            _waitForProjection.WaitOne();
            _waitForProjection.Reset();
            _waitForProjection.WaitOne();
            await Task.Delay(1000);

            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Name.Equals(_projection) &&
                     connectedProjection.State == ConnectedProjectionState.Subscribed);

            await PushToStream(Fixture.CreateMany <SomethingHappened>(4));

            await Task.Delay(500);

            var assertionContext = new ProjectionContext(CreateContextOptionsFor <ProjectionContext>());

            assertionContext.ProcessedEvents
            .Should()
            .ContainAll(
                PushedMessages,
                (processedMessage, message, i) => processedMessage.Position == i && processedMessage.Event == message.GetType().Name&& processedMessage.EvenTime == message.On);
        }
コード例 #2
0
        public async Task Then_the_projection_is_subscribed()
        {
            await ProjectionManager.Start(_projection, CancellationToken.None);

            await Task.Delay(1000);

            GetStateFor(_projection)
            .Should()
            .Be(ConnectedProjectionState.Subscribed);
        }
コード例 #3
0
        public async Task Then_all_projections_are_subscribed()
        {
            await ProjectionManager.Start(CancellationToken.None);

            await Task.Delay(1000);

            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .OnlyContain(connectedProjection => connectedProjection.State == ConnectedProjectionState.Subscribed);
        }
コード例 #4
0
        public async Task Then_the_projection_is_catching_up()
        {
            await ProjectionManager.Start(_projection, CancellationToken.None);

            _waitForProjection.WaitOne();
            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Id == _projection &&
                     connectedProjection.State == ConnectedProjectionState.CatchingUp);
        }
コード例 #5
0
        public void Then_the_projection_is_catching_up()
        {
            ProjectionManager.Start(_projection);

            _waitForProjection.WaitOne();
            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Name.Equals(_projection) &&
                     connectedProjection.State == ConnectedProjectionState.CatchingUp);
        }
コード例 #6
0
        protected override async Task Setup()
        {
            _waitForProjection = new AutoResetEvent(false);
            _projection        = new ConnectedProjectionName(typeof(TrackHandledEventsProjection));
            await PushToStream(Fixture.Create <SomethingHappened>());

            ProjectionManager.Start();
            _waitForProjection.WaitOne();
            _waitForProjection.Reset();
            ProjectionManager.Stop();
            await Task.Delay(500);
        }
コード例 #7
0
        public async Task Then_the_projection_is_subscribed()
        {
            await ProjectionManager.Start(_projection, CancellationToken.None);

            await Task.Delay(250);

            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Id == _projection &&
                     connectedProjection.State == ConnectedProjectionState.Subscribed);
        }
コード例 #8
0
        public async Task Then_the_projection_is_subscribed()
        {
            ProjectionManager.Start(_projection);

            await Task.Delay(250);

            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Name.Equals(_projection) &&
                     connectedProjection.State == ConnectedProjectionState.Subscribed);
        }
コード例 #9
0
        public async Task Then_the_projection_process_new_events()
        {
            ProjectionManager.Start(_projection);
            await Task.Delay(250);

            var somethingHappened = Fixture.Create <SomethingHappened>();

            await PushToStream(somethingHappened);

            _waitForProjection.WaitOne();
            await Task.Delay(100);

            var assertionContext = new ProjectionContext(CreateContextOptionsFor <ProjectionContext>());

            assertionContext.ProcessedEvents
            .Should().Contain(@event =>
                              @event.Position == PushedMessages.Count - 1 &&
                              @event.Event == somethingHappened.GetType().Name &&
                              @event.EvenTime == somethingHappened.On);
        }
コード例 #10
0
ファイル: HostProcess.cs プロジェクト: neuralaxis/carupano
        public static void Run(string[] args)
        {
            Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
            var asmFiles = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll");
            var builder  = new BoundedContextModelBuilder();
            var color    = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine($"Carupano Host");
            Console.ForegroundColor = color;
            Console.WriteLine("Inspecting available assemblies...");
            var configTypes = asmFiles.Select(a => Assembly.Load(new AssemblyName(Path.GetFileNameWithoutExtension(a))).GetTypes().SingleOrDefault(c => c.Name == "Startup")).Where(c => c != null);

            foreach (var config in configTypes)
            {
                Console.WriteLine($"\tFound Startup class {config.Name}");
                var method   = config.GetMethods().SingleOrDefault(c => c.Name == "Configure" && c.GetParameters().Count() == 1 && c.GetParameters().Single().ParameterType == builder.GetType());
                var instance = Activator.CreateInstance(config);
                method.Invoke(instance, new[] { builder });
                Console.WriteLine($"\tConfigured {config.Name}");
            }
            if (!configTypes.Any())
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("No Startup class(es) found.");
            }
            else
            {
                var model = builder.Build();
                var mgr   = new ProjectionManager(model.Services.GetService <IEventStore>(),
                                                  model.Services.GetService <IInboundMessageBus>(),
                                                  model.Projections.Select(c => c.CreateInstance(model.Services)));
                mgr.Start();
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Carupano is running...");
            }
            Console.ForegroundColor = ConsoleColor.Cyan;
            Console.WriteLine("Press any key to exit process.");
            Console.ReadKey();
        }
コード例 #11
0
        public async Task Then_the_events_pushed_to_the_store_while_subscribed_are_handled()
        {
            ProjectionManager.Start(_projection);
            // wait for projection to be in subscription
            while (GetStateFor(_projection) != ConnectedProjectionState.Subscribed)
            {
                await Task.Delay(25);
            }

            var message = Fixture.Create <SomethingHappened>();

            await PushToStream(message);

            _projectionStarted.WaitOne(1000);
            await Task.Delay(500);

            var assertContext = new ProjectionContext(CreateContextOptionsFor <ProjectionContext>());

            assertContext.ProcessedEvents
            .Should()
            .Contain(@event => @event.Position == 0L && @event.Event == message.GetType().Name&& @event.EvenTime == message.On);
        }
コード例 #12
0
        public async Task Then_the_projection_is_subscribed_once_caught_up()
        {
            ProjectionManager.Start(_projection);

            _waitForProjection.WaitOne();
            _waitForProjection.Reset();
            _waitForProjection.WaitOne();
            await Task.Delay(1000);

            ProjectionManager
            .GetRegisteredProjections()
            .Should()
            .Contain(connectedProjection =>
                     connectedProjection.Name.Equals(_projection) &&
                     connectedProjection.State == ConnectedProjectionState.Subscribed);
            var assertionContext = new ProjectionContext(CreateContextOptionsFor <ProjectionContext>());

            assertionContext.ProcessedEvents
            .Should()
            .ContainAll(
                PushedMessages,
                (processedMessage, message, i) => processedMessage.Position == i && processedMessage.Event == message.GetType().Name&& processedMessage.EvenTime == message.On);
        }
コード例 #13
0
        public async Task StartAsync(CancellationToken cancellationToken)
        {
            await _esConnection.ConnectAsync();

            await _projectionManager.Start();
        }
コード例 #14
0
ファイル: HostProcess.cs プロジェクト: neuralaxis/carupano
 public void Start()
 {
     _projections.Start();
 }