private async Task 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 logger = TestHarnessLoggerFactory.Create();

            var busBuilder = new BusBuilder().Configure()
                                             .WithNames("IntegrationTestHarness", Environment.MachineName)
                                             .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                             .WithTypesFrom(typeProvider)
                                             .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."))
                ;

            using (var bus = busBuilder.Build())
            {
                await bus.Start();
            }
        }
Exemple #2
0
        private static void Main(string[] args)
        {

            Timer = new Stopwatch();

            Timer.Start();
            const string connectionString =
                "Endpoint=sb://kno2-jferguson.servicebus.windows.net/;SharedAccessKeyName=Kno2;SharedAccessKey=YllaqQuGYa6WjZgMvCG8IlqC7IkDe49kCGkiUZQpZYs=";

            var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly(), typeof(DoStuff).Assembly);
            var b = new BusBuilder()
                .Configure()
                .WithConnectionString(connectionString)
                .WithTypesFrom(typeProvider)
            

                .WithDependencyResolver(new DependencyResolver(typeProvider))
                .WithNames("Ninja", Environment.MachineName)
                .WithSerializer(new JsonSerializer())
                .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                .Build();

            
          // b.Start().Wait();
            Console.WriteLine(Timer.ElapsedMilliseconds);


            Task.Run(
                async () =>
                      {
                          var doStuffs = new List<DoStuff>();
                          for (int i = 0; i < 20; i++)
                          {
                              doStuffs.Add(new DoStuff {Stuff = "Yola ola"});
                          }

                          await b.SendAll(doStuffs);
                      }
                );


            Task.Run(
                async () =>
                      {

                          for (int i = 0; i < 25; i++)
                          {

                              await b.PublishAsync(new NotifyStuff {Message = "Get on up"});
                              await b.PublishAsync(new NotifyStuff {Message = "Get on up 2"});
                          }

                      }
                );

            Console.WriteLine("Running..");
            Console.ReadKey();
        }
        public async Task ItShouldGoBangQuickly()
        {
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {GetType().Namespace});

            var logger = TestHarnessLoggerFactory.Create();

            var bus = new BusBuilder().Configure()
                                      .WithNames("IntegrationTestHarness", Environment.MachineName)
                                      .WithConnectionString(@"Endpoint=sb://shouldnotexist.example.com/;SharedAccessKeyName=IntegrationTestHarness;SharedAccessKey=borkborkbork=")
                                      .WithTypesFrom(typeProvider)
                                      .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                      .WithLogger(logger)
                                      .Build();

            await bus.Start();
        }
        public async Task TheStartupTimeShouldBeAcceptable()
        {
            const int numMessageTypes = 100;

            var assemblyBuilder = EmitMessageContractsAndHandlersAssembly(numMessageTypes);

            var logger = TestHarnessLoggerFactory.Create();
            var typeProvider = new AssemblyScanningTypeProvider(new[] {assemblyBuilder});

            var firstBus = new BusBuilder().Configure()
                                           .WithNames("MyTestSuite", Environment.MachineName)
                                           .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                           .WithTypesFrom(typeProvider)
                                           .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                           .WithServerConnectionCount(100)
                                           .WithLogger(logger)
                                           .Build();
            try
            {
                using (new AssertingStopwatch("First bus startup", TimeSpan.FromMinutes(1)))
                {
                    {
                        try
                        {
                            await firstBus.Start(MessageReceiverTypes.All);
                            WriteBlankLines();
                        }
                        catch (AggregateException exc)
                        {
                            throw exc.Flatten();
                        }
                    }
                }
            }
            finally
            {
                WriteBlankLines();
                firstBus.Dispose();
            }

            WriteBlankLines();

            var subsequentBus = new BusBuilder().Configure()
                                                .WithNames("MyTestSuite", Environment.MachineName)
                                                .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                                .WithTypesFrom(typeProvider)
                                                .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                                .WithLogger(logger)
                                                .Build();

            try
            {
                using (new AssertingStopwatch("Subsequent bus startup", TimeSpan.FromSeconds(20)))
                {
                    try
                    {
                        await subsequentBus.Start(MessageReceiverTypes.All);
                        WriteBlankLines();
                    }
                    catch (AggregateException exc)
                    {
                        throw exc.Flatten();
                    }
                }
            }
            finally
            {
                WriteBlankLines();
                subsequentBus.Dispose();
            }
        }
        private Task<Bus> BuildMeABus()
        {
            return Task.Run(async () =>
                                  {
                                      // 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 logger = TestHarnessLoggerFactory.Create();

                                      var bus = new BusBuilder().Configure()
                                                                .WithNames("IntegrationTestHarness", Environment.MachineName)
                                                                .WithConnectionString(CommonResources.ServiceBusConnectionString)
                                                                .WithTypesFrom(typeProvider)
                                                                .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                                                .WithLogger(logger)
                                                                .Build();
                                      bus.ShouldNotBe(null);
                                      await bus.Start();
                                      return bus;
                                  });
        }
Exemple #6
0
        private static void Main(string[] args)
        {
            XmlConfigurator.Configure();
            var logger = LogManager.GetLogger("test");
            logger.Debug("Debug");

            Enable("Local Area Connection");

            Timer = new Stopwatch();

            Timer.Start();
            const string connectionString =
                "Endpoint=sb://kno2-jferguson.servicebus.windows.net/;SharedAccessKeyName=Kno2;SharedAccessKey=YllaqQuGYa6WjZgMvCG8IlqC7IkDe49kCGkiUZQpZYs=";

            var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly(), typeof(DoStuff).Assembly);
            var b = new BusBuilder()
                .Configure()
                .WithConnectionString(connectionString)
                .WithTypesFrom(typeProvider)
                .WithDependencyResolver(new DependencyResolver(typeProvider))
                .WithNames("Ninja", Environment.MachineName)
                .WithSerializer(new JsonSerializer())
                .WithDefaultTimeout(TimeSpan.FromSeconds(2))
                .WithEnableEnablePartitioning(true)
                .WithLog4netLogger(logger)
                .Build();

            
          // b.Start().Wait();
            Console.WriteLine(Timer.ElapsedMilliseconds);

            //Disable("Local Area Connection");

            Thread.Sleep(2000);

            Task.Run(
                async () =>
                      {
                          var doStuffs = new List<DoStuff>();

                          for (int i = 0; i < 100; i++)
                          {
                              if (i == 10)
                              {
                                  
                              }
                              //doStuffs.Add(new DoStuff {Stuff = "Yola ola"});
                              await b.SendAsync(new DoStuff { Stuff = "Yola ola " + i });
                          }

                          //await b.SendAll(doStuffs);
                      }
                );


            //Task.Run(
            //    async () =>
            //          {
            //              for (int i = 0; i < 25; i++)
            //              {

            //                  await b.PublishAsync(new NotifyStuff {Message = "Get on up"});
            //                  await b.PublishAsync(new NotifyStuff {Message = "Get on up 2"});
            //              }

            //          }
            //    );

            
            Console.WriteLine("Running..");
            Console.ReadKey();
        }