Exemplo n.º 1
0
        private void RegisterInterceptors(IIocRegistrator reg, ITypeFinder typeFinder)
        {
            reg.RegisterInstance(new TestContextInterceptor());
            FindTypesByMethodReturnValueAndRegisterInterceptor <IEnumerable <ExecutionResult>, TestContextInterceptor>(
                reg, typeFinder);

            reg.RegisterInstance(new TestContextStepInterceptor());
            FindTypesByMethodReturnValueAndRegisterInterceptor <ExecutionResult, TestContextStepInterceptor>(reg,
                                                                                                             typeFinder);

            RegisterCommanders(reg, typeFinder);
        }
Exemplo n.º 2
0
        private void RegisterCommanders(IIocRegistrator reg, ITypeFinder typeFinder)
        {
            reg.RegisterInstance(new TestContextStepPartInterceptor());

            var commanderTypes = typeFinder.FindClassesOfType <ICommander>();

            if (!commanderTypes.Any())
            {
                throw new AutomationException("Failed to find commander implementors. Please register commanders");
            }

            foreach (var ct in commanderTypes)
            {
                var firstLevelCommanderInterfaces = GetFirstLevelInterfaces(ct)
                                                    .Where(t => typeof(ICommander).IsAssignableFrom(t));

                firstLevelCommanderInterfaces.ForEachItem(flci =>
                                                          reg.RegisterType(ct, flci, LifeCycle.PerDependency,
                                                                           interceptorTypes: new[] { typeof(TestContextStepPartInterceptor) }));
            }
        }