protected override async Task Given(AllDependencyResolversTestContext context)
        {

            await base.Given(context);

            var clock = new SystemClock();
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {GetType().Namespace});
            var serializer = new DataContractSerializer(typeProvider);
            var replyQueueNameSetting = new ReplyQueueNameSetting(
                new ApplicationNameSetting {Value = "TestApplication"},
                new InstanceNameSetting {Value = "TestInstance"});

            var handlerMap = new HandlerMapper(typeProvider).GetFullHandlerMap(typeof (IHandleCommand<>));

            _brokeredMessageFactory = new BrokeredMessageFactory(new MaxLargeMessageSizeSetting(),
                                                                 new MaxSmallMessageSizeSetting(),
                                                                 replyQueueNameSetting,
                                                                 clock,
                                                                 new NullCompressor(),
                                                                 new DispatchContextManager(),
                                                                 new UnsupportedLargeMessageBodyStore(),
                                                                 serializer,
                                                                 typeProvider);

            _commandDispatcher = new CommandMessageDispatcher(_brokeredMessageFactory,
                                                              new SystemClock(),
                                                              Subject,
                                                              new NullInboundInterceptorFactory(),
                                                              new NullLogger(),
                                                              handlerMap);
        }
        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();
            }
        }
        public static IEnumerable<IDependencyResolver> GetAllDependencyResolvers(TestHarnessTypeProvider typeProvider)
        {
            var dependencyResolvers = AssembliesToScan
                .SelectMany(a => a.GetExportedTypes())
                .Where(t => typeof (IDependencyResolverFactory).IsAssignableFrom(t))
                .Where(t => t.IsInstantiable())
                .Select(Activator.CreateInstance)
                .Cast<IDependencyResolverFactory>()
                .Select(factory => factory.Create(typeProvider))
                .ToArray();

            return dependencyResolvers;
        }
 protected async Task<BrokeredMessageFactory> Given()
 {
     var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {GetType().Namespace});
     return new BrokeredMessageFactory(new MaxLargeMessageSizeSetting(),
                                       new MaxSmallMessageSizeSetting {Value = 64*1024},
                                       new ReplyQueueNameSetting(new ApplicationNameSetting {Value = "SomeApp"}, new InstanceNameSetting {Value = "SomeInstance"}),
                                       new SystemClock(),
                                       new NullCompressor(),
                                       new DispatchContextManager(),
                                       new UnsupportedLargeMessageBodyStore(),
                                       new DataContractSerializer(typeProvider),
                                       typeProvider);
 }
Ejemplo n.º 5
0
        public IEnumerable<TestCaseData> TestCases()
        {
            var typeProvider = new TestHarnessTypeProvider(new[] {Assembly.GetExecutingAssembly()}, new[] {GetType().Namespace});

            return AssembliesToScan
                .SelectMany(a => a.GetExportedTypes())
                .Where(t => typeof (IDependencyResolverFactory).IsAssignableFrom(t))
                .Where(t => t.IsInstantiable())
                .Select(Activator.CreateInstance)
                .Cast<IDependencyResolverFactory>()
                .Select(factory => new AllDependencyResolversTestContext(factory, typeProvider))
                .Select(context => new TestCaseData(context).SetName(context.TestName))
                ;
        }
        public async Task ItShouldGoBangQuickly()
        {
            var typeProvider = new TestHarnessTypeProvider(new[] {GetType().Assembly}, new[] {GetType().Namespace});

            var logger = new ConsoleLogger();

            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();
        }
        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;
                                  });
        }