Example #1
0
        public QUnitTestAdapter(IFrameworkAdapter js, string qUnitJs)
            : base(js)
        {
            Trace.Assert(!String.IsNullOrWhiteSpace(qUnitJs));
              Trace.Assert(File.Exists(qUnitJs));
              Trace.Assert(js != null);

              this.qUnitJs = qUnitJs;
        }
Example #2
0
        public JasmineTestAdapter(IFrameworkAdapter js, string jasminJsFile)
            : base(js)
        {
            Trace.Assert(js != null);
              Trace.Assert(!String.IsNullOrWhiteSpace(jasminJsFile));
              Trace.Assert(File.Exists(jasminJsFile));

              this.jasminJsFile = jasminJsFile;
        }
Example #3
0
        public JSUnitTestAdapter(IFrameworkAdapter js, string jsUnitCoreFile)
            : base(js)
        {
            Trace.Assert(js != null);
              Trace.Assert(!String.IsNullOrWhiteSpace(jsUnitCoreFile));
              Trace.Assert(File.Exists(jsUnitCoreFile));

              this.jsUnitCoreFile = jsUnitCoreFile;
        }
Example #4
0
        public void PropertyDependency(IFrameworkAdapter framework)
        {
            framework.Register <IService, IndependentService>();
            framework.Register <ServiceWithSimplePropertyDependency>();

            var component = framework.Resolve <ServiceWithSimplePropertyDependency>();

            Assert.NotNull(component.Service);
            Assert.IsAssignableFrom <IndependentService>(component.Service);
        }
Example #5
0
 public static void RegisterTypes(
     this IReadOnlyDictionary <Type, List <RegisterDependencyAttribute> > types,
     IFrameworkAdapter services
     )
 {
     foreach (var(type, attributes) in types)
     {
         type.RegisterAttributes(attributes, services);
     }
 }
Example #6
0
        public void ConstructorDependencyUsingInstance(IFrameworkAdapter framework)
        {
            var instance = new IndependentService();

            framework.Register <IService>(instance);
            framework.Register <ServiceWithSimpleConstructorDependency>();

            var dependent = framework.Resolve <ServiceWithSimpleConstructorDependency>();

            Assert.Same(instance, dependent.Service);
        }
Example #7
0
        public void TransientFactoryUsedBySingletonStillCreatesTransient(IFrameworkAdapter framework)
        {
            framework.RegisterTransient <IService, IndependentService>();
            framework.RegisterSingleton <ServiceWithFuncConstructorDependency>();

            var service = framework.Resolve <ServiceWithFuncConstructorDependency>();
            var first   = service.Factory();
            var second  = service.Factory();

            Assert.NotSame(first, second);
        }
Example #8
0
 private static void RegisterAttributes(
     this Type implementationType,
     IEnumerable <RegisterDependencyAttribute> attributes,
     IFrameworkAdapter services
     )
 {
     foreach (var attribute in attributes)
     {
         services.RegisterAttribute(implementationType, attribute);
     }
 }
Example #9
0
        private void AssertIsNotCrashingOnRecursion(IFrameworkAdapter adapter)
        {
            if (!adapter.CrashesOnRecursion)
            {
                return;
            }

            throw new AssertException(string.Format(
                                          "{0} fails recursion for now, and we have no way to retest it in each run (without process crash).",
                                          adapter.FrameworkName
                                          ));
        }
Example #10
0
        private void AssertGivesCorrectExceptionWhenResolvingRecursive <TService>(IFrameworkAdapter framework)
        {
            try {
                framework.Resolve <TService>();
            }
            catch (Exception ex) {
                Debug.WriteLine(framework.GetType().Name + " throws following on recursion: " + ex);
                return;
            }

            throw new AssertException("No exception for recursion, either this use case is not supported or there is some other issue.");
        }
Example #11
0
        public void FactoryWithNoParameters(IFrameworkAdapter framework)
        {
            framework.Register <IService, IndependentService>();
            framework.Register <ServiceWithSimpleConstructorDependency>();

            var func = framework.Resolve <Func <ServiceWithSimpleConstructorDependency> >();

            Assert.NotNull(func);
            var result = func();

            Assert.NotNull(result);
        }
Example #12
0
        public void AssertResolvesListDependencyFor <TTestComponent>(IFrameworkAdapter framework)
            where TTestComponent : IServiceWithListDependency <IEnumerable <IService> >
        {
            framework.Register <IService, IndependentService>();
            framework.Register <TTestComponent>();

            var resolved = framework.Resolve <TTestComponent>();

            Assert.NotNull(resolved);
            Assert.NotNull(resolved.Services);
            Assert.Equal(1, resolved.Services.Count());
            Assert.IsAssignableFrom <IndependentService>(resolved.Services.First());
        }
Example #13
0
        public void ReasonableConstructorSelection(IFrameworkAdapter framework)
        {
            framework.Register <IService, IndependentService>();
            framework.Register <ServiceWithMultipleConstructors>();

            var resolved = framework.Resolve <ServiceWithMultipleConstructors>();

            Assert.NotNull(resolved);
            Assert.Equal(
                ServiceWithMultipleConstructors.ConstructorNames.MostResolvable,
                resolved.UsedConstructorName
                );
        }
Example #14
0
        public int GetScore(IFrameworkAdapter framework)
        {
            if (this.Scoring == FeatureScoring.NotScored)
            {
                return(0);
            }

            if (this.Scoring == FeatureScoring.PointPerTable)
            {
                return(this.Features.Any(f => this[framework, f].State == FeatureState.Success) ? 1 : 0);
            }

            return(this.Features.Count(f => this[framework, f].State == FeatureState.Success));
        }
Example #15
0
        public void FactoryWithParameter(IFrameworkAdapter framework)
        {
            framework.Register <IService, IndependentService>();
            framework.Register <ServiceWithTwoConstructorDependencies>();
            var service2 = new IndependentService2();

            var func = framework.Resolve <Func <IService2, ServiceWithTwoConstructorDependencies> >();

            Assert.NotNull(func);
            var result = func(service2);

            Assert.NotNull(result);
            Assert.Same(service2, result.Service2);
        }
        public void Activate()
        {
            VerifyDisposed();
            IProfilingTargetAdapter    adapter    = _profilingTarget.GetSafeAdapter();
            IProfilingTargetController controller = adapter.CreateController(_configurationSettings);

            //Select all Frameworks that involved into profiling and notify them
            foreach (FrameworkSettings frameworkSettings in _configurationSettings.FrameworksSettings)
            {
                IFramework        framework        = _frameworks[frameworkSettings.Uid];
                IFrameworkAdapter frameworkAdapter = framework.GetSafeAdapter();
                frameworkAdapter.ConfigureForProfiling(_configurationSettings);
            }
            //Start profiling
            controller.Start();
            controller.TargetStopped += OnControllerTargetStopped;
            lock (_controllers)
            {
                _controllers.Add(controller);
            }
        }
        private FeatureTestRun RunTest(MethodInfo test, IFrameworkAdapter framework)
        {
            var frameworkType = framework.GetType();
            var specialCase   = GetSpecialCase(test, frameworkType)
                                ?? GetSpecialCase(test.DeclaringType, frameworkType);

            if (specialCase != null && specialCase.Skip)
            {
                return(new FeatureTestRun(test, frameworkType, FeatureTestResult.SkippedDueToSpecialCase, specialCase.Comment));
            }

            var instance = Activator.CreateInstance(test.DeclaringType);

            try {
                test.Invoke(instance, new object[] { framework });
            }
            catch (Exception ex) {
                return(new FeatureTestRun(test, frameworkType, FeatureTestResult.Failure, exception: ToUsefulException(ex)));
            }

            var comment = specialCase != null ? specialCase.Comment : null;

            return(new FeatureTestRun(test, frameworkType, FeatureTestResult.Success, comment));
        }
 public static void RegisterTransient <TService, TImplementation>(this IFrameworkAdapter container)
     where TImplementation : TService
 {
     container.RegisterTransient(typeof(TService), typeof(TImplementation));
 }
 public static void RegisterInstance(this IFrameworkAdapter container, object instance)
 {
     container.RegisterInstance(instance.GetType(), instance);
 }
 public static void RegisterInstance <TService>(this IFrameworkAdapter container, TService instance)
 {
     container.RegisterInstance(typeof(TService), instance);
 }
Example #21
0
        protected AbstractTestAdapter(IFrameworkAdapter js)
        {
            Trace.Assert(js != null);

              this.js = js;
        }
 public static TService Resolve <TService>(this IFrameworkAdapter container)
 {
     return((TService)container.Resolve(typeof(TService)));
 }
Example #23
0
 public void Array(IFrameworkAdapter framework)
 {
     this.AssertResolvesListDependencyFor <ServiceWithListConstructorDependency <IService[]> >(framework);
 }
 public static IEnumerable <TService> ResolveAll <TService>(this IFrameworkAdapter container)
 {
     return(container.ResolveAll(typeof(TService)).Cast <TService>());
 }
Example #25
0
 private IDictionary <string, object> GetAllFeatureData(IFrameworkAdapter framework, IEnumerable <FeatureTable> tables)
 {
     return(tables.Where(t => t.Key != MetadataKeys.GeneralTable && t.Key != MetadataKeys.NetFxVersionTable)
            .SelectMany(t => t.Features.Select(f => GetSingleFeatureData(f, t[framework, f])))
            .ToDictionary(p => p.Key, p => p.Value));
 }
Example #26
0
 public ClosureTestAdapter(IFrameworkAdapter js) : base(js)
 {
 }
Example #27
0
 public ClosureTestAdapter(IFrameworkAdapter js)
     : base(js)
 {
 }
Example #28
0
        protected AbstractTestAdapter(IFrameworkAdapter js)
        {
            Trace.Assert(js != null);

            this.js = js;
        }
Example #29
0
 public void IReadOnlyList(IFrameworkAdapter framework)
 {
     this.AssertResolvesListDependencyFor <ServiceWithListConstructorDependency <IReadOnlyList <IService> > >(framework);
 }
Example #30
0
 public void Enumerable(IFrameworkAdapter framework)
 {
     this.AssertResolvesListDependencyFor <ServiceWithListConstructorDependency <IEnumerable <IService> > >(framework);
 }
Example #31
0
 public void Collection(IFrameworkAdapter framework)
 {
     this.AssertResolvesListDependencyFor <ServiceWithListConstructorDependency <ICollection <IService> > >(framework);
 }
 public static void RegisterTransient <TService>(this IFrameworkAdapter container)
 {
     container.RegisterSingleton <TService, TService>();
 }
 public static void Register <TService>(this IFrameworkAdapter container)
 {
     container.Register <TService, TService>();
 }
Example #34
0
 public FeatureCell this[IFrameworkAdapter framework, object featureKey] {
     get { return(this.cells[Tuple.Create(framework.FrameworkName, featureKey)]); }
 }
Example #35
0
 public FeatureTestCommand(IMethodInfo method, IFrameworkAdapter adapter)
     : base(method, adapter.FrameworkName, MethodUtility.GetTimeoutParameter(method))
 {
     this.adapter = adapter;
 }