public void CreateUserAndAccount_WillAcceptBothObjectsAndDictionariesForExtendedParameters() { // since it is a static helper - you gotta love 'em AppDomainUtils.RunInSeparateAppDomain(() => { // we need that in order to make sure the Membership static class is initialized correctly var discard = Membership.Provider as ProviderBase; // Arrange var providerMock = new Mock <ExtendedMembershipProvider>(); providerMock.Setup( p => p.CreateUserAndAccount(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <IDictionary <string, object> >())) .Returns((string username, string password, bool requireConfirmation, IDictionary <string, object> values) => "foo = " + values["foo"]); typeof(Membership).GetField("s_Provider", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, providerMock.Object); // Act var resultWithObject = WebSecurity.CreateUserAndAccount("name", "pass", new { foo = "bar" }); var resultWithDictionary = WebSecurity.CreateUserAndAccount("name", "pass", new Dictionary <string, object> { { "foo", "baz" } }); // Assert Assert.Equal("foo = bar", resultWithObject); Assert.Equal("foo = baz", resultWithDictionary); }); }
public void FileExistsReturnsTrueForExistingPath_VPPRegistrationChanging() { AppDomainUtils.RunInSeparateAppDomain(() => { // Arrange AppDomainUtils.SetAppData(); new HostingEnvironment(); // Expect null beforeProvider since hosting environment hasn't been initialized VirtualPathProvider beforeProvider = HostingEnvironment.VirtualPathProvider; string testPath = "/Path.txt"; VirtualPathProvider afterProvider = CreatePathProvider(testPath); Mock <VirtualPathProvider> mockProvider = Mock.Get(afterProvider); TestableBuildManagerViewEngine engine = new TestableBuildManagerViewEngine(); // Act VirtualPathProvider beforeEngineProvider = engine.VirtualPathProvider; HostingEnvironment.RegisterVirtualPathProvider(afterProvider); bool result = engine.FileExists(testPath); VirtualPathProvider afterEngineProvider = engine.VirtualPathProvider; // Assert Assert.True(result); Assert.Equal(beforeProvider, beforeEngineProvider); Assert.Equal(afterProvider, afterEngineProvider); mockProvider.Verify(); mockProvider.Verify(c => c.FileExists(It.IsAny <String>()), Times.Once()); }); }
public void createAppDomainAndAllDependencies() { string fullPathToDllToProcess = Path.Combine(hardCodedO2DevelopmentLib, o2DllToProcess + ".exe"); // AppDomainUtils.findDllInCurrentAppDomain(o2DllToProcess); DI.log.debug("For the dll: {0}", o2DllToProcess); Dictionary <string, string> assemblyDependencies = new CecilAssemblyDependencies(fullPathToDllToProcess).calculateDependencies(); DI.log.debug("There are {0} assembly dependencies to load", assemblyDependencies.Count); var o2AppDomainFactory = new O2AppDomainFactory(); Assert.That(o2AppDomainFactory.load(assemblyDependencies).Count == 0, "There were assemblyDependencies that were not loaded"); DI.log.d("List of loaded Assemblies"); foreach (string assembly in o2AppDomainFactory.getAssemblies(true)) { DI.log.d(" - " + assembly); } AppDomainUtils.closeAppDomain(o2AppDomainFactory.appDomain, onTestCompletionDeleteTempFilesCreated); }
public void GetVersionIgnoresUnsignedConfigDll() { AppDomainUtils.RunInSeparateAppDomain( () => { // Arrange - Load v2 Config Assembly asm = Assembly.LoadFrom( Path.Combine( _tempPath, @"ConfigTestAssemblies\V2_Unsigned\System.Web.WebPages.Deployment.dll" ) ); Assert.Equal(new Version(2, 0, 0, 0), asm.GetName().Version); Assert.Equal("System.Web.WebPages.Deployment", asm.GetName().Name); using (WebUtils.CreateHttpRuntime(@"~\foo", ".")) { // Act Version ver = WebPagesDeployment.GetVersionWithoutEnabledCheck( Path.Combine(_tempPath, @"ConfigTestSites\CshtmlFileNoVersion") ); // Assert Assert.Equal(new Version("1.0.0.0"), ver); } } ); }
public void GetVersionReturnsLowerVersionIfSpecifiedInConfigAndNotExplicitlyDisabled() { AppDomainUtils.RunInSeparateAppDomain( () => { // Arrange - Load v2 Config Assembly asm = Assembly.LoadFrom( Path.Combine( _tempPath, @"ConfigTestAssemblies\V2_Signed\System.Web.WebPages.Deployment.dll" ) ); Assert.Equal(new Version(2, 0, 0, 0), asm.GetName().Version); Assert.Equal("System.Web.WebPages.Deployment", asm.GetName().Name); using (WebUtils.CreateHttpRuntime(@"~\foo", ".")) { string path = Path.Combine(_tempPath, @"ConfigTestSites\NoCshtmlConfigV1"); // Act Version ver = WebPagesDeployment.GetVersionWithoutEnabledCheck(path); Version explicitVersion = WebPagesDeployment.GetExplicitWebPagesVersion( path ); // Assert Assert.Equal(new Version(1, 0, 0, 0), ver); Assert.Equal(new Version(1, 0, 0, 0), explicitVersion); } } ); }
public void TestAnalyzerLoading_AppDomain() { var dir = Temp.CreateDirectory(); dir.CopyFile(typeof(AppDomainUtils).Assembly.Location); dir.CopyFile(typeof(RemoteAnalyzerFileReferenceTest).Assembly.Location); var analyzerFile = DesktopTestHelpers.CreateCSharpAnalyzerAssemblyWithTestAnalyzer( dir, "MyAnalyzer" ); var loadDomain = AppDomainUtils.Create("AnalyzerTestDomain", basePath: dir.Path); try { // Test analyzer load success. var remoteTest = (RemoteAnalyzerFileReferenceTest)loadDomain.CreateInstanceAndUnwrap( typeof(RemoteAnalyzerFileReferenceTest).Assembly.FullName, typeof(RemoteAnalyzerFileReferenceTest).FullName ); var exception = remoteTest.LoadAnalyzer(analyzerFile.Path); Assert.Null(exception); } finally { AppDomain.Unload(loadDomain); } }
public void UrlAnonymousObjectTest() { AppDomainUtils.RunInSeparateAppDomain( () => { using ( IDisposable _ = Utils.CreateHttpContext( "default.aspx", "http://localhost/" ), __ = Utils.CreateHttpRuntime("/") ) { Assert.Equal( "/world/test.cshtml?Prop1=value1", UrlUtil.GenerateClientUrl( new HttpContextWrapper(HttpContext.Current), "~/world/page.cshtml", "test.cshtml", new { Prop1 = "value1" } ) ); Assert.Equal( "/world/test.cshtml?Prop1=value1&Prop2=value2", UrlUtil.GenerateClientUrl( new HttpContextWrapper(HttpContext.Current), "~/world/page.cshtml", "test.cshtml", new { Prop1 = "value1", Prop2 = "value2" } ) ); } } ); }
public void IsWithinAppRootTest() { AppDomainUtils.RunInSeparateAppDomain( () => { var root = "/website1"; using (Utils.CreateHttpRuntime(root)) { Assert.True(PathUtil.IsWithinAppRoot(root, "~/")); Assert.True(PathUtil.IsWithinAppRoot(root, "~/default.cshtml")); Assert.True(PathUtil.IsWithinAppRoot(root, "~/test/default.cshtml")); Assert.True(PathUtil.IsWithinAppRoot(root, "/website1")); Assert.True(PathUtil.IsWithinAppRoot(root, "/website1/")); Assert.True(PathUtil.IsWithinAppRoot(root, "/website1/default.cshtml")); Assert.True( PathUtil.IsWithinAppRoot(root, "/website1/test/default.cshtml") ); Assert.False(PathUtil.IsWithinAppRoot(root, "/")); Assert.False(PathUtil.IsWithinAppRoot(root, "/website2")); Assert.False(PathUtil.IsWithinAppRoot(root, "/subfolder1/")); } } ); }
public void GenerateClientUrl_ResolvesRelativePathToSubfolder_WithApplicationPath() { AppDomainUtils.RunInSeparateAppDomain(() => { using (IDisposable _ = Utils.CreateHttpContext("default.aspx", "http://localhost/WebSite1/subfolder1/default.aspx"), __ = Utils.CreateHttpRuntime("/WebSite1/")) { // Arrange var vpath = "~/subfolder1/default.aspx"; var href = "world/test.aspx"; var expected = "/WebSite1/subfolder1/world/test.aspx"; var context = new HttpContextWrapper(HttpContext.Current); var page = new MockPage() { VirtualPath = vpath, Context = context }; // Act var actual1 = UrlUtil.GenerateClientUrl(context, vpath, href); var actual2 = page.Href(href); // Assert Assert.Equal(expected, actual1); Assert.Equal(expected, actual2); } }); }
static DI() { //Apply .NET Network Connection hack O2Kernel_Web.ApplyNetworkConnectionHack(); // all these variables need to be setup appDomainsControledByO2Kernel = new Dictionary <string, O2AppDomainFactory>(); log = new KO2Log(); reflection = new KReflection(); o2MessageQueue = KO2MessageQueue.getO2KernelQueue(); // before we load the O2Config data (which is loaded from the local disk) config = O2ConfigLoader.getKO2Config(); //make sure theses values are set (could be a prob due to changed location of these values) if (config.LocalScriptsFolder == null) { config.LocalScriptsFolder = KO2Config.defaultLocalScriptFolder; config.SvnO2RootFolder = KO2Config.defaultSvnO2RootFolder; config.SvnO2DatabaseRulesFolder = KO2Config.defaultSvnO2DatabaseRulesFolder; } O2KernelProcessName = "Generic O2 Kernel Process";; AppDomainUtils.registerCurrentAppDomain(); }
public void createAppDomainAndLoadDll_MainTestCase() { string fullPathToDllToProcess = DI.config.ExecutingAssembly; //Path.Combine(hardCodedO2DevelopmentLib, o2DllToProcess + ".exe"); //AppDomainUtils.findDllInCurrentAppDomain(o2DllToProcess); Assert.That(File.Exists(fullPathToDllToProcess), "fullPathToDllToProcess doesn't exist:" + fullPathToDllToProcess); // get test AppDomain in temp folder var o2AppDomainFactory = new O2AppDomainFactory(); // load dll from it (this will fail until all dependencies are resolved Assert.That(o2AppDomainFactory.load(o2DllToProcess, fullPathToDllToProcess, true), "Dll failed to load into AppDomain"); // get assemblyDependencies Dictionary <string, string> assemblyDependencies = new CecilAssemblyDependencies(fullPathToDllToProcess).calculateDependencies(); DI.log.debug("There are {0} assembly dependencies to load", assemblyDependencies.Count); // load them and abort if we were not able to load all) Assert.That(o2AppDomainFactory.load(assemblyDependencies).Count == 0, "There were assemblyDependencies that were not loaded"); // double check that all is OK by dinamcally invoking some methods on the new AppDomain Assert.That(null != o2AppDomainFactory.invokeMethod("nameOfCurrentDomainStatic O2Proxy O2_Kernel", new object[0]), "Could not invoke methods inside O2_CoreLib"); o2AppDomainFactory.invokeMethod("logInfo O2Proxy O2_Kernel", new object[] { "Hello from createAppDomainInTempFolder UnitTest" }); AppDomainUtils.closeAppDomain(o2AppDomainFactory.appDomain, onTestCompletionDeleteTempFilesCreated); }
public void StartApplicationTest() { AppDomainUtils.RunInSeparateAppDomain( () => { var moduleEvents = new ModuleEvents(); var app = new MyHttpApplication(); WebPageHttpModule.StartApplication( app, moduleEvents.ExecuteStartPage, moduleEvents.ApplicationStart ); Assert.Equal(1, moduleEvents.CalledExecuteStartPage); Assert.Equal(1, moduleEvents.CalledApplicationStart); // Call a second time to make sure the methods are only called once WebPageHttpModule.StartApplication( app, moduleEvents.ExecuteStartPage, moduleEvents.ApplicationStart ); Assert.Equal(1, moduleEvents.CalledExecuteStartPage); Assert.Equal(1, moduleEvents.CalledApplicationStart); } ); }
public void GetProviderHtml_DoesNotContainBadRazorCompilation() { AppDomainUtils.RunInSeparateAppDomain( () => { // Arrange var stubbedContext = new Mock <HttpContextBase>(); var contextItems = new Hashtable(); stubbedContext.SetupGet(x => x.Items).Returns(contextItems); Maps.GetCurrentHttpContext = () => stubbedContext.Object; // Act string bingResults = Maps.GetBingHtml( "somekey", latitude: "100", longitude: "10" ) .ToHtmlString(); string googleResults = Maps.GetGoogleHtml(latitude: "100", longitude: "10") .ToHtmlString(); string mapQuestResults = Maps.GetMapQuestHtml( "somekey", latitude: "100", longitude: "10" ) .ToHtmlString(); // Assert Assert.DoesNotContain("<text>", bingResults); Assert.DoesNotContain("<text>", googleResults); Assert.DoesNotContain("<text>", mapQuestResults); } ); }
public void GetVersionReturnsV1IfCshtmlFilePresentButNoVersionIsSpecifiedInConfigOrBin() { AppDomainUtils.RunInSeparateAppDomain( () => { // Arrange - Load v2 Config Assembly asm = Assembly.LoadFrom( Path.Combine( _tempPath, @"ConfigTestAssemblies\V2_Signed\System.Web.WebPages.Deployment.dll" ) ); Assert.Equal(new Version(2, 0, 0, 0), asm.GetName().Version); Assert.Equal("System.Web.WebPages.Deployment", asm.GetName().Name); using (WebUtils.CreateHttpRuntime(@"~\foo", ".")) { string path = Path.Combine( _tempPath, @"ConfigTestSites\CshtmlFileNoVersion" ); // Act Version ver = WebPagesDeployment.GetVersionWithoutEnabledCheck(path); Version explicitVersion = WebPagesDeployment.GetExplicitWebPagesVersion( path ); // Assert Assert.Equal(new Version("1.0.0.0"), ver); Assert.Null(explicitVersion); } } ); }
public void StartTest() { AppDomainUtils.RunInSeparateAppDomain( () => { AppDomainUtils.SetPreAppStartStage(); PreApplicationStartCode.Start(); // Call a second time to ensure multiple calls do not cause issues PreApplicationStartCode.Start(); Assert.False( RouteTable.Routes.RouteExistingFiles, "We should not be setting RouteExistingFiles" ); Assert.Empty(RouteTable.Routes); Assert.False(PageParser.EnableLongStringsAsResources); string formsAuthLoginUrl = (string)typeof(FormsAuthentication) .GetField("_LoginUrl", BindingFlags.Static | BindingFlags.NonPublic) .GetValue(null); Assert.Null(formsAuthLoginUrl); } ); }
public void HtmlEncodeTest() { AppDomainUtils.RunInSeparateAppDomain( () => { // Set HideRequestResponse to true to simulate the condition in IIS 7/7.5 var context = new HttpContext( new HttpRequest("default.cshtml", "http://localhost/default.cshtml", null), new HttpResponse(new StringWriter(new StringBuilder())) ); var hideRequestResponse = typeof(HttpContext).GetField( "HideRequestResponse", BindingFlags.NonPublic | BindingFlags.Instance ); hideRequestResponse.SetValue(context, true); HttpContext.Current = context; var page = new ApplicationStartPageTest().CreateStartPage( p => { p.Write("test"); } ); page.ExecuteStartPage(); } ); }
public void ExecuteWithinInitTest() { AppDomainUtils.RunInSeparateAppDomain( () => { Utils.CreateHttpRuntime("/subfolder1/website1"); new HostingEnvironment(); var stringSet = Activator.CreateInstance( typeof(BuildManager).Assembly.GetType("System.Web.Util.StringSet"), true ); typeof(BuildManager) .GetField( "_forbiddenTopLevelDirectories", BindingFlags.Instance | BindingFlags.NonPublic ) .SetValue(new MockInitPage().GetBuildManager(), stringSet); ; var init = new MockInitPage() { VirtualPath = "~/_pagestart.cshtml", ExecuteAction = p => { }, }; var page = Utils.CreatePage(p => { }); Utils.AssignObjectFactoriesAndDisplayModeProvider(page, init); var result = Utils.RenderWebPage(page); } ); }
public void loadDefaultSetOfFilesToConvert() { dotNetAssembliesToConvert.clearMappings(); dotNetAssembliesToConvert.setExtensionsToShow(".dll .exe"); dotNetAssembliesToConvert.addFiles(CompileEngine.getListOfO2AssembliesInExecutionDir()); dotNetAssembliesToConvert.addFiles(AppDomainUtils.getDllsInCurrentAppDomain_FullPath()); runOnLoad = false; }
public void StartTest() { AppDomainUtils.RunInSeparateAppDomain(() => { AppDomainUtils.SetPreAppStartStage(); PreApplicationStartCode.Start(); var buildProviders = typeof(BuildProvider).GetField("s_dynamicallyRegisteredProviders", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); Assert.AreEqual(2, buildProviders.GetType().GetProperty("Count", BindingFlags.Public | BindingFlags.Instance).GetValue(buildProviders, new object[] { })); }); }
public void StartCanRunTwice() { AppDomainUtils.RunInSeparateAppDomain(() => { AppDomainUtils.SetPreAppStartStage(); PreApplicationStartCode.Start(); // Call a second time to ensure multiple calls do not cause issues PreApplicationStartCode.Start(); }); }
public void TestAnalyzerLoading_Error() { var analyzerSource = @" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using System.Runtime.InteropServices; [DiagnosticAnalyzer(LanguageNames.CSharp)] [StructLayout(LayoutKind.Sequential, Size = 10000000)] public class TestAnalyzer : DiagnosticAnalyzer { public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { throw new NotImplementedException(); } } public override void Initialize(AnalysisContext context) { throw new NotImplementedException(); } }"; var dir = Temp.CreateDirectory(); dir.CopyFile(typeof(System.Reflection.Metadata.MetadataReader).Assembly.Location); dir.CopyFile(typeof(AppDomainUtils).Assembly.Location); dir.CopyFile(typeof(Memory <>).Assembly.Location); dir.CopyFile(typeof(System.Runtime.CompilerServices.Unsafe).Assembly.Location); var immutable = dir.CopyFile(typeof(ImmutableArray).Assembly.Location); var analyzer = dir.CopyFile(typeof(DiagnosticAnalyzer).Assembly.Location); dir.CopyFile(typeof(RemoteAnalyzerFileReferenceTest).Assembly.Location); var analyzerCompilation = CSharp.CSharpCompilation.Create( "MyAnalyzer", new SyntaxTree[] { CSharp.SyntaxFactory.ParseSyntaxTree(analyzerSource) }, new MetadataReference[] { TestMetadata.NetStandard20.mscorlib, TestMetadata.NetStandard20.netstandard, TestMetadata.NetStandard20.SystemRuntime, MetadataReference.CreateFromFile(immutable.Path), MetadataReference.CreateFromFile(analyzer.Path) }, new CSharp.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var analyzerFile = dir.CreateFile("MyAnalyzer.dll").WriteAllBytes(analyzerCompilation.EmitToArray()); var loadDomain = AppDomainUtils.Create("AnalyzerTestDomain", basePath: dir.Path); try { // Test analyzer load failure. var remoteTest = (RemoteAnalyzerFileReferenceTest)loadDomain.CreateInstanceAndUnwrap(typeof(RemoteAnalyzerFileReferenceTest).Assembly.FullName, typeof(RemoteAnalyzerFileReferenceTest).FullName); var exception = remoteTest.LoadAnalyzer(analyzerFile.Path); Assert.NotNull(exception as TypeLoadException); } finally { AppDomain.Unload(loadDomain); } }
public void TestAnalyzerLoading_Error() { var analyzerSource = @" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; using System.Runtime.InteropServices; [DiagnosticAnalyzer(LanguageNames.CSharp)] [StructLayout(LayoutKind.Sequential, Size = 10000000)] public class TestAnalyzer : DiagnosticAnalyzer { public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics { get { throw new NotImplementedException(); } } public override void Initialize(AnalysisContext context) { throw new NotImplementedException(); } }"; var dir = Temp.CreateDirectory(); var metadata = dir.CopyFile(typeof(System.Reflection.Metadata.MetadataReader).Assembly.Location); var immutable = dir.CopyFile(typeof(ImmutableArray).Assembly.Location); var analyzer = dir.CopyFile(typeof(DiagnosticAnalyzer).Assembly.Location); var test = dir.CopyFile(typeof(FromFileLoader).Assembly.Location); // The other app domain in 64-bit tries to load xunit.dll so to work around bug 4959 // (https://github.com/dotnet/roslyn/issues/4959) we are copying xunit to the test directory. if (Environment.Is64BitProcess) { var xunit = dir.CopyFile(typeof(FactAttribute).Assembly.Location); } var analyzerCompilation = CSharp.CSharpCompilation.Create( "MyAnalyzer", new SyntaxTree[] { CSharp.SyntaxFactory.ParseSyntaxTree(analyzerSource) }, new MetadataReference[] { SystemRuntimePP7Ref, MetadataReference.CreateFromFile(immutable.Path), MetadataReference.CreateFromFile(analyzer.Path) }, new CSharp.CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); var analyzerFile = dir.CreateFile("MyAnalyzer.dll").WriteAllBytes(analyzerCompilation.EmitToArray()); var loadDomain = AppDomainUtils.Create("AnalyzerTestDomain", basePath: dir.Path); try { var remoteTest = (RemoteAnalyzerFileReferenceTest)loadDomain.CreateInstanceAndUnwrap(typeof(RemoteAnalyzerFileReferenceTest).Assembly.FullName, typeof(RemoteAnalyzerFileReferenceTest).FullName); remoteTest.SetAssert(RemoteAssert.Instance); remoteTest.TestTypeLoadException(analyzerFile.Path); } finally { AppDomain.Unload(loadDomain); } }
public void FileExistsTest() { AppDomainUtils.RunInSeparateAppDomain(() => { var path = "~/index.cshtml"; Utils.SetupVirtualPathInAppDomain(path, ""); var cache = FileExistenceCache.GetInstance(); Assert.IsTrue(cache.FileExists(path)); Assert.IsFalse(cache.FileExists("~/test.cshtml")); }); }
public void InitializeApplicationTest() { AppDomainUtils.RunInSeparateAppDomain(() => { var moduleEvents = new ModuleEvents(); var app = new MyHttpApplication(); WebPageHttpModule.InitializeApplication(app, moduleEvents.OnApplicationPostResolveRequestCache, moduleEvents.Initialize); Assert.IsTrue(moduleEvents.CalledInitialize); }); }
public void StartInitializesFormsAuthByDefault() { AppDomainUtils.RunInSeparateAppDomain(() => { AppDomainUtils.SetPreAppStartStage(); PreApplicationStartCode.Start(); string formsAuthLoginUrl = (string)typeof(FormsAuthentication).GetField("_LoginUrl", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); Assert.Equal(FormsAuthenticationSettings.DefaultLoginUrl, formsAuthLoginUrl); }); }
public static bool closeAscxGui() { var o2AppDomainFactory = AppDomainUtils.getO2AppDomainFactoryForCurrentO2Kernel(); var result = o2AppDomainFactory.invoke("O2AscxGUI O2_External_WinFormsUI", "close", null); if (result is bool) { return((bool)result); } return(false); }
public void StartTest() { AppDomainUtils.RunInSeparateAppDomain(() => { // Act AppDomainUtils.SetPreAppStartStage(); PreApplicationStartCode.Start(); // Assert var imports = WebPageRazorHost.GetGlobalImports(); Assert.IsTrue(imports.Any(ns => ns.Equals("Microsoft.Web.Helpers"))); }); }
public void ExceptionTest() { AppDomainUtils.RunInSeparateAppDomain(() => { var msg = "This is an error message"; var e = new InvalidOperationException(msg); var page = new ApplicationStartPageTest().CreateStartPage(p => { throw e; }); var ex = Assert.Throws <HttpException>(() => page.ExecuteStartPage()); Assert.Equal(msg, ex.InnerException.Message); Assert.Equal(e, ApplicationStartPage.Exception); }); }
public void StartDoesNotInitializeFormsAuthWhenDisabled() { AppDomainUtils.RunInSeparateAppDomain(() => { AppDomainUtils.SetPreAppStartStage(); ConfigurationManager.AppSettings[WebSecurity.EnableSimpleMembershipKey] = "False"; PreApplicationStartCode.Start(); string formsAuthLoginUrl = (string)typeof(FormsAuthentication).GetField("_LoginUrl", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null); Assert.Null(formsAuthLoginUrl); }); }
public void StartPageBasicTest() { AppDomainUtils.RunInSeparateAppDomain(() => { var page = new ApplicationStartPageTest().CreateStartPage(p => { p.AppState["x"] = "y"; p.WriteLiteral("test"); }); page.ExecuteInternal(); Assert.AreEqual("y", page.ApplicationState["x"]); Assert.AreEqual("test", ApplicationStartPage.Markup.ToHtmlString()); }); }