public void TheMessageShouldMentionTheOffendingTypeByName()
        {
            var assemblyScanningTypeProvider = new AssemblyScanningTypeProvider(typeof (UnserializableCommandWhoseAssemblyShouldNotBeIncluded).Assembly);

            var validationErrors = assemblyScanningTypeProvider.Validate().ToArray();

            validationErrors.ShouldContain(e => e.Contains(typeof (UnserializableCommandWhoseAssemblyShouldNotBeIncluded).FullName));
        }
Example #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 NothingShouldGoBang()
        {
            var typeProvider = new AssemblyScanningTypeProvider(GetType().Assembly);

            var builder = new ContainerBuilder();
            builder.RegisterZombus(typeProvider);

            using (builder.Build()) { }
        }
        public void NothingShouldGoBang()
        {
            var builder = new ContainerBuilder();
            var typeProvider = new AssemblyScanningTypeProvider();

            builder.RegisterType<ConsoleLogger>()
                   .As<IZombusLogger>()
                   .SingleInstance();

            builder.RegisterZombus(typeProvider);

            var largeMessageBodyTempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Guid.NewGuid().ToString());

            builder.Register(c => new FileSystemStorageBuilder().Configure()
                                                                .WithStorageDirectory(largeMessageBodyTempPath)
                                                                .WithLogger(c.Resolve<IZombusLogger>())
                                                                .Build())
                   .As<ILargeMessageBodyStore>()
                   .SingleInstance();

            builder.Register(c => new BusBuilder().Configure()
                                                  .WithNames("IntegrationTestHarness", Environment.MachineName)
                                                  .WithConnectionString(
                                                      @"Endpoint=sb://shouldnotexist.example.com/;SharedAccessKeyName=IntegrationTestHarness;SharedAccessKey=borkborkbork=")
                                                  .WithLargeMessageStorage(sc => sc.WithLargeMessageBodyStore(c.Resolve<ILargeMessageBodyStore>())
                                                                                   .WithMaxSmallMessageSize(50*1024)
                                                                                   .WithMaxLargeMessageSize(1024*1024))
                                                  .WithTypesFrom(typeProvider)
                                                  .WithDefaultTimeout(TimeSpan.FromSeconds(10))
                                                  .WithLogger(c.Resolve<IZombusLogger>())
                                                  .Build())
                   .As<IBus>()
                   .SingleInstance();

            using (var container = builder.Build())
            {
                container.Resolve<IBus>();
            }
        }
Example #5
0
        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();
            }
        }
 public void ValidationShouldFail()
 {
     var assemblyScanningTypeProvider = new AssemblyScanningTypeProvider(typeof (CommandWhoseAssemblyShouldNotBeIncludedHandler).Assembly);
     assemblyScanningTypeProvider.Validate().ShouldNotBeEmpty();
 }
Example #7
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();
        }
 public void ValidationShouldFail()
 {
     var assemblyScanningTypeProvider = new AssemblyScanningTypeProvider(Assembly.GetAssembly(typeof (DuplicateMessageType)));
     assemblyScanningTypeProvider.Validate().ShouldNotBeEmpty();
 }