Ejemplo n.º 1
0
        public virtual void SetUp()
        {
            // should not need this if all other tests were clean
            // but hey, never know, better avoid garbage-in
            Reset();

            // get/merge the attributes marking the method and/or the classes
            Options = TestOptionAttributeBase.GetTestOptions <UmbracoTestAttribute>();

            // fixme - align to runtimes & components - don't redo everything here

            var(logger, profiler) = GetLoggers(Options.Logger);
            var proflogger     = new ProfilingLogger(logger, profiler);
            var cacheHelper    = GetCacheHelper();
            var globalSettings = SettingsForTests.GetDefaultGlobalSettings();
            var typeLoader     = GetTypeLoader(cacheHelper.RuntimeCache, globalSettings, proflogger, Options.TypeLoader);

            var register = RegisterFactory.Create();

            Composition = new Composition(register, typeLoader, proflogger, ComponentTests.MockRuntimeState(RuntimeLevel.Run));

            Composition.RegisterUnique(typeLoader);
            Composition.RegisterUnique(logger);
            Composition.RegisterUnique(profiler);
            Composition.RegisterUnique <IProfilingLogger>(proflogger);
            Composition.RegisterUnique(cacheHelper);
            Composition.RegisterUnique(cacheHelper.RuntimeCache);

            TestObjects = new TestObjects(register);
            Compose();
            Current.Factory = Factory = Composition.CreateFactory();
            Initialize();
        }
Ejemplo n.º 2
0
 protected virtual TestOptionAttributeBase Merge(TestOptionAttributeBase other)
 {
     return(this);
 }
Ejemplo n.º 3
0
        public virtual void SetUp()
        {
            // should not need this if all other tests were clean
            // but hey, never know, better avoid garbage-in
            Reset();

            // get/merge the attributes marking the method and/or the classes
            Options = TestOptionAttributeBase.GetTestOptions <UmbracoTestAttribute>();

            // FIXME: align to runtimes & components - don't redo everything here !!!! Yes this is getting painful

            var loggerFactory = GetLoggerFactory(Options.Logger);

            _loggerFactory = loggerFactory;
            var profiler   = new LogProfiler(loggerFactory.CreateLogger <LogProfiler>());
            var msLogger   = loggerFactory.CreateLogger("msLogger");
            var proflogger = new ProfilingLogger(loggerFactory.CreateLogger <ProfilingLogger>(), profiler);

            IOHelper = TestHelper.IOHelper;

            TypeFinder = new TypeFinder(loggerFactory.CreateLogger <TypeFinder>(), new DefaultUmbracoAssemblyProvider(GetType().Assembly, loggerFactory), new VaryingRuntimeHash());
            var appCaches      = GetAppCaches();
            var globalSettings = new GlobalSettings();
            var settings       = new WebRoutingSettings();

            IBackOfficeInfo backOfficeInfo = new AspNetBackOfficeInfo(globalSettings, IOHelper, loggerFactory.CreateLogger <AspNetBackOfficeInfo>(), Microsoft.Extensions.Options.Options.Create(settings));
            IIpResolver     ipResolver     = new AspNetIpResolver();

            UmbracoVersion = new UmbracoVersion();


            LocalizedTextService = new LocalizedTextService(new Dictionary <CultureInfo, Lazy <XDocument> >(), loggerFactory.CreateLogger <LocalizedTextService>());
            var typeLoader = GetTypeLoader(IOHelper, TypeFinder, appCaches.RuntimeCache, HostingEnvironment, loggerFactory.CreateLogger <TypeLoader>(), proflogger, Options.TypeLoader);

            var services = TestHelper.GetRegister();

            Builder = new UmbracoBuilder(services, Mock.Of <IConfiguration>(), typeLoader);

            //TestHelper.GetConfigs().RegisterWith(register);
            services.AddUnique(typeof(ILoggerFactory), loggerFactory);
            services.AddTransient(typeof(ILogger <>), typeof(Logger <>));
            services.AddSingleton <ILogger>(msLogger);
            services.AddUnique(IOHelper);
            services.AddUnique(UriUtility);
            services.AddUnique(UmbracoVersion);
            services.AddUnique(TypeFinder);
            services.AddUnique(LocalizedTextService);
            services.AddUnique(typeLoader);
            services.AddUnique <IProfiler>(profiler);
            services.AddUnique <IProfilingLogger>(proflogger);
            services.AddUnique(appCaches);
            services.AddUnique(HostingEnvironment);
            services.AddUnique(backOfficeInfo);
            services.AddUnique(ipResolver);
            services.AddUnique <IPasswordHasher, AspNetPasswordHasher>();
            services.AddUnique(TestHelper.ShortStringHelper);
            //services.AddUnique<IPublicAccessChecker, PublicAccessChecker>();


            var memberService     = Mock.Of <IMemberService>();
            var memberTypeService = Mock.Of <IMemberTypeService>();

            TestObjects = new TestObjects();
            Compose();
            Current.Factory = Factory = TestHelper.CreateServiceProvider(Builder);
            Initialize();
        }