/// <summary> /// Initializes a new instance of the <see cref="RequestManager"/> class. /// </summary> /// <param name="initializationManager">The initialization action discoverer.</param> protected RequestManager(InitializationManager initializationManager) { if (initializationManager == null) { throw new ArgumentNullException("initializationManager"); } this.initializationManager = initializationManager; }
/// <summary> /// Initializes a new instance of the <see cref="LiveTestTest"/> class. /// </summary> public LiveTestTest() { this.testApplication = Substitute.For<TestApplication>(); this.initializationManager = Substitute.For<InitializationManager>(Substitute.For<InitializationActionDiscoverer>(), Substitute.For<InitializationActionExecutor>()); LiveTestBase.TestApplicationManager.StartApplication(Arg.Is<TestApplicationHost>(host => (host.ApplicationId == "Sitecore.LiveTesting.Default") && (host.VirtualPath == "/") && (host.PhysicalPath == "..\\Website"))).Returns(this.testApplication); this.realTest = new TestWithCustomInstantiation(this.initializationManager); }
/// <summary> /// Initializes a new instance of the <see cref="WorkerRequest"/> class. /// </summary> /// <param name="initializationManager">The initialization Manager.</param> /// <param name="context">The request initialization context.</param> /// <param name="writer">The writer.</param> internal WorkerRequest(InitializationManager initializationManager, RequestInitializationContext context, TextWriter writer) : base(context.Request.Path, context.Request.QueryString, writer) { if (initializationManager == null) { throw new ArgumentNullException("initializationManager"); } if (context == null) { throw new ArgumentNullException("context"); } this.connectionId = Interlocked.Increment(ref connectionCount); this.initializationManager = initializationManager; this.context = context; }
/// <summary> /// Initializes a new instance of the <see cref="TestApplication"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> protected TestApplication(InitializationManager initializationManager) { if (initializationManager == null) { throw new ArgumentNullException("initializationManager"); } if (HostingEnvironment.IsHosted) { HostingEnvironment.RegisterObject(this); // INFO: workaround to avoid AppDomainUnloadedException because of Sitecore agents object hostingEnvironment = typeof(HostingEnvironment).GetField("_theHostingEnvironment", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); EventHandler eventHandler = (EventHandler)typeof(HostingEnvironment).GetField("_onAppDomainUnload", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(hostingEnvironment); Thread.GetDomain().DomainUnload -= eventHandler; } this.initializationManager = initializationManager; this.initializationManager.Initialize(0, new TestApplicationInitializationContext(this)); }
/// <summary> /// Initializes a new instance of the <see cref="Test"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> public Test(InitializationManager initializationManager) : base(initializationManager) { }
/// <summary> /// Initializes a new instance of the <see cref="TestWithCustomInstantiation"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> public TestWithCustomInstantiation(InitializationManager initializationManager) : base(initializationManager) { }
/// <summary> /// Initializes a new instance of the <see cref="LiveTestBase"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> public LiveTestBase(InitializationManager initializationManager) : base(initializationManager) { }
/// <summary> /// Initializes a new instance of the <see cref="LiveTest"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> protected LiveTest(InitializationManager initializationManager) { this.initializationManager = initializationManager; }
/// <summary> /// Initializes a new instance of the <see cref="LiveTestWithInitialization"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> protected LiveTestWithInitialization(InitializationManager initializationManager) : base(initializationManager) { }
/// <summary> /// Initializes a new instance of the <see cref="CustomTestApplication"/> class. /// </summary> /// <param name="initializationManager">The initialization manager.</param> public CustomTestApplication(InitializationManager initializationManager) : base(initializationManager) { }
public void ShouldExecuteInitializersInReverseOrderOnCleanup() { const int MethodCallId = 123; this.manager = new InitializationManager(this.actionDiscoverer, this.actionExecutor, new Dictionary<int, IList<InitializationAction>> { { MethodCallId, new[] { new InitializationAction("Action1"), new InitializationAction("Action2") } } }); this.manager.Cleanup(MethodCallId, null); Received.InOrder( () => { this.actionExecutor.ExecuteCleanupForAction(Arg.Is<InitializationAction>(action => action.Id == "Action2")); this.actionExecutor.ExecuteCleanupForAction(Arg.Is<InitializationAction>(action => action.Id == "Action1")); }); }
/// <summary> /// Initializes a new instance of the <see cref="InitializationManagerTest"/> class. /// </summary> public InitializationManagerTest() { this.actionDiscoverer = Substitute.For<TestInitializationActionDiscoverer>(); this.actionExecutor = Substitute.For<InitializationActionExecutor>(); this.manager = new InitializationManager(this.actionDiscoverer, this.actionExecutor); }