public void Init() { var builder = new ContainerBuilder(); builder.RegisterType<DefaultProcessingEngine>().As<IProcessingEngine>(); builder.RegisterModule(new WorkContextModule()); builder.RegisterType<WorkContextAccessor>().As<IWorkContextAccessor>(); builder.RegisterAutoMocking(MockBehavior.Loose); _container = builder.Build(); _shellContext = new ShellContext { Descriptor = new ShellDescriptor(), Settings = new ShellSettings(), LifetimeScope = _container.BeginLifetimeScope(), }; _container.Mock<IShellContextFactory>() .Setup(x => x.CreateDescribedContext(_shellContext.Settings, _shellContext.Descriptor)) .Returns(_shellContext); _container.Mock<IHttpContextAccessor>() .Setup(x=>x.Current()) .Returns(default(HttpContextBase)); }
/// <summary> /// Starts a Shell and registers its settings in RunningShellTable /// </summary> private void ActivateShell(ShellContext context) { Logger.Debug("Activating context for tenant {0}", context.Settings.Name); context.Shell.Activate(); _shellContexts = (_shellContexts ?? Enumerable.Empty<ShellContext>()) .Where(c => c.Settings.Name != context.Settings.Name) .Concat(new[] { context }) .ToArray(); _runningShellTable.Add(context.Settings); }