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; }
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; }
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; }
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); }
public static void RegisterTypes( this IReadOnlyDictionary <Type, List <RegisterDependencyAttribute> > types, IFrameworkAdapter services ) { foreach (var(type, attributes) in types) { type.RegisterAttributes(attributes, services); } }
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); }
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); }
private static void RegisterAttributes( this Type implementationType, IEnumerable <RegisterDependencyAttribute> attributes, IFrameworkAdapter services ) { foreach (var attribute in attributes) { services.RegisterAttribute(implementationType, attribute); } }
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 )); }
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."); }
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); }
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()); }
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 ); }
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)); }
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); }
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))); }
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>()); }
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)); }
public ClosureTestAdapter(IFrameworkAdapter js) : base(js) { }
public ClosureTestAdapter(IFrameworkAdapter js) : base(js) { }
protected AbstractTestAdapter(IFrameworkAdapter js) { Trace.Assert(js != null); this.js = js; }
public void IReadOnlyList(IFrameworkAdapter framework) { this.AssertResolvesListDependencyFor <ServiceWithListConstructorDependency <IReadOnlyList <IService> > >(framework); }
public void Enumerable(IFrameworkAdapter framework) { this.AssertResolvesListDependencyFor <ServiceWithListConstructorDependency <IEnumerable <IService> > >(framework); }
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>(); }
public FeatureCell this[IFrameworkAdapter framework, object featureKey] { get { return(this.cells[Tuple.Create(framework.FrameworkName, featureKey)]); } }
public FeatureTestCommand(IMethodInfo method, IFrameworkAdapter adapter) : base(method, adapter.FrameworkName, MethodUtility.GetTimeoutParameter(method)) { this.adapter = adapter; }