Exemplo n.º 1
0
 protected CommandBusSpecification()
 {
     Bus       = new CommandBus("Fixture Bus", slowMsgThreshold: TimeSpan.FromMilliseconds(500));
     LocalBus  = new CommandBus("Fixture LocalBus");
     TestQueue = new TestQueue(Bus);
     try
     {
         Given();
         When();
     }
     catch (Exception)
     {
         throw;
     }
 }
        protected CommandQueueSpecification(
            int queueCount = 1,
            int slowCmdMs  = 500,
            int slowAckMs  = 500)
        {
            Bus = new CommandBus(
                "Fixture Bus",
                slowCmdThreshold: TimeSpan.FromMilliseconds(slowCmdMs),
                slowMsgThreshold: TimeSpan.FromMilliseconds(slowAckMs));

            Queue = new MultiQueuedHandler(
                queueCount,
                index => new QueuedHandler(
                    new AdHocHandler <Message>(
                        msg =>
            {
                if (msg is Command)
                {
                    Bus.TryFire((Command)msg);
                }
                else
                {
                    Bus.Publish(msg);
                }
            }),
                    $"Queue {index}"
                    )
                );
            Queue.Start();
            TestQueue = new TestQueue(Bus);
            try
            {
                Given();
                When();
            }
            catch (Exception)
            {
                throw;
            }
        }