private void ClearMeABus()
        {
            // Filter types we care about to only our own test's namespace. It's a performance optimisation because creating and
            // deleting queues and topics is slow.
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {"Some.Namespace.That.Does.Not.Exist"});
            var messageBroker = new DefaultMessageBroker(typeProvider);

            var logger = new ConsoleLogger();

            var bus = new BusBuilder().Configure()
                                      .WithNames("MyTestSuite", Environment.MachineName)
                                      .WithConnectionString(CommonResources.ConnectionString)
                                      .WithTypesFrom(typeProvider)
                                      .WithCommandBroker(messageBroker)
                                      .WithRequestBroker(messageBroker)
                                      .WithMulticastEventBroker(messageBroker)
                                      .WithCompetingEventBroker(messageBroker)
                                      .WithMulticastRequestBroker(messageBroker)
                                      .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                      .WithLogger(logger)
                                      .WithDebugOptions(
                                          dc =>
                                              dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                  "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                                      .Build();
        }
Example #2
0
            public IBus Create()
            {
                var messageBroker = new DefaultMessageBroker(_typeProvider);

                var bus = TestHarnessBusFactory.CreateAndStart(_typeProvider, messageBroker);
                return bus;
            }
        public void DoFoo()
        {
            var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly());
            IMulticastEventBroker multicastEventBroker = new DefaultMessageBroker(typeProvider);

            var bus = new BusBuilder().Configure()
                                      .WithConnectionString("foo")
                                      .WithNames("MyApp", Environment.MachineName)
                                      .WithTypesFrom(typeProvider)
                                      .WithMulticastEventBroker(multicastEventBroker)
                                      .Build();
        }
Example #4
0
        public static Bus CreateAndStart(ITypeProvider typeProvider, DefaultMessageBroker messageBroker)
        {
            var logger = new ConsoleLogger();

            var bus = new BusBuilder().Configure()
                                      .WithNames("MyTestSuite", Environment.MachineName)
                                      .WithConnectionString(CommonResources.ConnectionString)
                                      .WithTypesFrom(typeProvider)
                                      .WithCommandBroker(messageBroker)
                                      .WithRequestBroker(messageBroker)
                                      .WithMulticastEventBroker(messageBroker)
                                      .WithCompetingEventBroker(messageBroker)
                                      .WithMulticastRequestBroker(messageBroker)
                                      .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                      .WithLogger(logger)
                                      .WithDebugOptions(
                                          dc =>
                                              dc.RemoveAllExistingNamespaceElementsOnStartup(
                                                  "I understand this will delete EVERYTHING in my namespace. I promise to only use this for test suites."))
                                      .Build();
            bus.Start();
            return bus;
        }
        private void BuildMeABus()
        {
            // Filter types we care about to only our own test's namespace. It's a performance optimisation because creating and
            // deleting queues and topics is slow.
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {GetType().Namespace});
            var messageBroker = new DefaultMessageBroker(typeProvider);

            var logger = new ConsoleLogger();

            var bus = new BusBuilder().Configure()
                                      .WithNames("MyTestSuite", Environment.MachineName)
                                      .WithConnectionString(CommonResources.ConnectionString)
                                      .WithTypesFrom(typeProvider)
                                      .WithCommandBroker(messageBroker)
                                      .WithRequestBroker(messageBroker)
                                      .WithMulticastEventBroker(messageBroker)
                                      .WithCompetingEventBroker(messageBroker)
                                      .WithMulticastRequestBroker(messageBroker)
                                      .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                      .WithLogger(logger)
                                      .Build();
            bus.ShouldNotBe(null);
        }
Example #6
0
        static void Main(string[] args)
        {

            // This is how you tell Nimbus where to find all your message types and handlers.
            var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly(), typeof(NewOrderRecieved).Assembly, typeof(OrderPizzaCommand).Assembly);

            var messageBroker = new DefaultMessageBroker(typeProvider);

            var connectionString = ConfigurationManager.AppSettings["AzureConnectionString"];

            var bus = new BusBuilder().Configure()
                                        .WithNames("Ordering", Environment.MachineName)
                                        .WithConnectionString(connectionString)
                                        .WithTypesFrom(typeProvider)
                                        .WithCommandBroker(messageBroker)
                                        .WithRequestBroker(messageBroker)
                                        .WithMulticastEventBroker(messageBroker)
                                        .WithCompetingEventBroker(messageBroker)
                                        .WithMulticastRequestBroker(messageBroker)
                                        .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                        .Build();
            bus.Start();


            Console.WriteLine("Press 1 to get the current wait time.");
            Console.WriteLine("Press 2 to order a pizza.");
            Console.WriteLine("Press 3 to Quit.");


            int nextPizzaId = 1;

            while (true)
            {

                var input = Console.ReadLine();

                switch (input)
                {
                    case "1":

#pragma warning disable 4014
                        FindOutHowLongItWillBe(bus);
#pragma warning restore 4014

                        break;

                    case "2":

                        var command = new OrderPizzaCommand {PizzaId = nextPizzaId};

#pragma warning disable 4014
                        bus.Send(command);
#pragma warning restore 4014


                        Console.WriteLine("Pizza number {0} ordered", nextPizzaId);
                        nextPizzaId++;

                        break;
                    
                    case "3":
                        bus.Stop();
                        return;

                    default:
                        continue;
                        
                }


            }

        }
Example #7
0
        public override void Given()
        {
            base.Given();

            _messageBroker = new DefaultMessageBroker();
        }