public when_logging_disabled_and_commands_are_fired(StreamStoreConnectionFixture fixture) : base(fixture.Connection)
        {
            // command must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _multiFireCount   = 0;
            _testCommandCount = 0;

            _listener = new SynchronizableStreamListener(
                Logging.FullStreamName,
                Connection,
                StreamNameBuilder,
                EventSerializer);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);
            CorrelatedMessage source = CorrelatedMessage.NewRoot();

            // create and fire a set of commands
            for (int i = 0; i < _maxCountedCommands; i++)
            {
                // this is just an example command - choice to fire this one was random
                var cmd = new TestCommands.Command2(source);
                Bus.Send(cmd,
                         $"exception message{i}",
                         TimeSpan.FromSeconds(2));
                source = cmd;
            }
            var tstCmd = new TestCommands.Command3(source);

            Bus.Send(tstCmd,
                     "Test Command exception message",
                     TimeSpan.FromSeconds(1));
        }
        protected override void When()
        {
            _correlationId = Guid.NewGuid();

            // command must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _multiFireCount   = 0;
            _testCommandCount = 0;

            _listener = Repo.GetListener(Logging.FullStreamName);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);

            // create and fire a set of commands
            for (int i = 0; i < MaxCountedCommands; i++)
            {
                // this is just an example command - choice to fire this one was random
                var cmd = new TestCommands.TestCommand2(
                    Guid.NewGuid(),
                    null);
                Bus.Fire(cmd,
                         $"exception message{i}",
                         TimeSpan.FromSeconds(2));
            }
            var tstCmd = new TestCommands.TestCommand3(
                Guid.NewGuid(),
                null);

            Bus.Fire(tstCmd,
                     "Test Command exception message",
                     TimeSpan.FromSeconds(1));
        }
예제 #3
0
        private TestCommandSubscriber _cmdHandler; // "never used" is a red herring. It handles the command


        protected override void When()
        {
            // command must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _multiFireCount = 0;

            _listener = Repo.GetListener(Logging.FullStreamName);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);
        }
예제 #4
0
        protected override void When()
        {
            _listener = Repo.GetListener(Logging.FullStreamName);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);

            _countedEventCount    = 0;
            _testDomainEventCount = 0;

            _cmdHandler = new TestCommandSubscriber(Bus);

            _multiFireCount   = 0;
            _testCommandCount = 0;

            _listener = Repo.GetListener(Logging.FullStreamName);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);

            // create and fire a mixed set of commands and events
            for (int i = 0; i < _maxCountedMessages; i++)
            {
                Bus.Publish(
                    new CountedEvent(i,
                                     _correlationId,
                                     Guid.NewGuid()));

                // this is just an example command - choice to fire this one was random
                var cmd = new TestCommands.TestCommand2(
                    Guid.NewGuid(),
                    null);
                Bus.Fire(cmd,
                         $"exception message{i}",
                         TimeSpan.FromSeconds(2));
            }

            for (int i = 0; i < _maxCountedEvents; i++)
            {
                Bus.Publish(new TestDomainEvent(_correlationId, Guid.NewGuid()));
            }

            var tstCmd = new TestCommands.TestCommand3(
                Guid.NewGuid(),
                null);

            Bus.Fire(tstCmd,
                     "Test Command exception message",
                     TimeSpan.FromSeconds(1));
        }
        public when_toggling_logging(StreamStoreConnectionFixture fixture) : base(fixture.Connection)
        {
            // command must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _multiFireCount = 0;

            _listener = new SynchronizableStreamListener(
                Logging.FullStreamName,
                Connection,
                StreamNameBuilder,
                EventSerializer);

            _listener.Start(Logging.FullStreamName);
        }
        protected override void When()
        {
            // commands must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _commandFireCount        = 0;
            _commandAckCount         = 0;
            _commandSuccessCount     = 0;
            _lastCommandCount        = 0;
            _countedEventCount       = 0;
            _testDomainEventCount    = 0;
            _numberOfItemsLogged     = 0;
            _catchupSubscriptionMsgs = 0;

            _listener = Repo.GetListener(Logging.FullStreamName);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);

            // create and fire a mixed set of commands and events
            for (int i = 0; i < _maxCountedMessages; i++)
            {
                Bus.Publish(
                    new CountedEvent(i,
                                     Guid.NewGuid(),
                                     Guid.NewGuid()));

                // this is just an example command - choice to fire this one was random
                var cmd = new TestCommands.TestCommand2(
                    Guid.NewGuid(),
                    null);
                Bus.Fire(cmd,
                         $"exception message{i}",
                         TimeSpan.FromSeconds(2));

                Bus.Publish(new TestDomainEvent(Guid.NewGuid(), Guid.NewGuid()));
            }

            var tstCmd = new TestCommands.TestCommand3(
                _correlationId,
                null);

            Bus.Fire(tstCmd,
                     "TestCommand3 failed",
                     TimeSpan.FromSeconds(2));
        }
예제 #7
0
        public when_mixed_messages_are_published(StreamStoreConnectionFixture fixture) : base(fixture.Connection)
        {
            // commands must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _multiFireCount   = 0;
            _testCommandCount = 0;

            IListener listener = new SynchronizableStreamListener(
                Logging.FullStreamName,
                Connection,
                StreamNameBuilder,
                EventSerializer);

            listener.EventStream.Subscribe <Message>(this);

            listener.Start(Logging.FullStreamName);
            CorrelatedMessage source = CorrelatedMessage.NewRoot();

            // create and fire a mixed set of commands and events
            for (int i = 0; i < _maxCountedMessages; i++)
            {
                // this is just an example command - choice to fire this one was random
                var cmd = new TestCommands.Command2(source);
                Bus.Send(cmd,
                         $"exception message{i}",
                         TimeSpan.FromSeconds(2));
                var evt = new CountedEvent(i, cmd);
                Bus.Publish(evt);
                source = evt;
            }
            Bus.Subscribe(new AdHocHandler <TestEvent>(_ => Interlocked.Increment(ref _gotEvt)));

            for (int i = 0; i < _maxCountedEvents; i++)
            {
                var evt = new TestEvent(source);
                Bus.Publish(evt);
                source = evt;
            }

            var tstCmd = new TestCommands.Command3(source);

            Bus.Send(tstCmd,
                     "Test Command exception message",
                     TimeSpan.FromSeconds(1));
        }
        public when_logging_high_volume_message_traffic(StreamStoreConnectionFixture fixture) : base(fixture.Connection)
        {
            // commands must have a commandHandler
            _cmdHandler = new TestCommandSubscriber(Bus);

            _commandFireCount        = 0;
            _commandAckCount         = 0;
            _commandSuccessCount     = 0;
            _lastCommandCount        = 0;
            _countedEventCount       = 0;
            _testDomainEventCount    = 0;
            _numberOfItemsLogged     = 0;
            _catchupSubscriptionMsgs = 0;

            _listener = new SynchronizableStreamListener(
                Logging.FullStreamName,
                Connection,
                StreamNameBuilder,
                EventSerializer);
            _listener.EventStream.Subscribe <Message>(this);

            _listener.Start(Logging.FullStreamName);
            CorrelatedMessage source = CorrelatedMessage.NewRoot();

            // create and fire a mixed set of commands and events
            for (int i = 0; i < _maxCountedMessages; i++)
            {
                var evt = new CountedEvent(i, source);
                Bus.Publish(evt);
                // this is just an example command - choice to fire this one was random
                var cmd = new TestCommands.Command2(evt);
                Bus.Send(cmd, $"exception message{i}", TimeSpan.FromSeconds(2));
                var evt2 = new TestEvent(cmd);
                Bus.Publish(evt2);
                source = evt2;
            }
            var tstCmd = new TestCommands.Command3(source);

            Bus.Send(tstCmd,
                     "TestCommand3 failed",
                     TimeSpan.FromSeconds(2));
        }
예제 #9
0
        public void can_handle_all_messages()
        {
            TestQueue.Clear();

            var cmdHandler = new TestCommandSubscriber(Bus);

            // this is just an example command - choice to fire this one was random
            var cmd = new TestCommands.TestCommand2(
                Guid.NewGuid(),
                null);

            Bus.Fire(cmd,
                     "exception message",
                     TimeSpan.FromSeconds(5));

            Assert.IsOrBecomesTrue(
                () => BusMessages.Count == 3,
                1000,
                $"Expected 3 bus messages for TestCommand2, found {BusMessages.Count}");


            Message deQdMsg;

            if (BusMessages.TryDequeue(out deQdMsg))
            {
                Assert.IsAssignableFrom <Message>(deQdMsg);
            }

            if (BusMessages.TryDequeue(out deQdMsg))
            {
                Assert.IsAssignableFrom <Message>(deQdMsg);
            }

            if (BusMessages.TryDequeue(out deQdMsg))
            {
                Assert.IsAssignableFrom <Message>(deQdMsg);
            }
        }