public void Switch404PageTest() { const string ERRORS = "HttpErrors"; string sAppPath = Memba.Tests.Memba_Install_WebInstallerAccessor.W3SVC + "/" + Constants.ServerNum + "/ROOT/" + Constants.VirtualDir; string sSite = Memba.Tests.Memba_Install_WebInstallerAccessor.METABASEROOT + Constants.ServerNum; //Find 404 page string s404Page = Path.Combine(TestContext.TestDir, "..\\..\\XP\\404.htm"); FileInfo objFileInfo = new FileInfo(s404Page); Assert.IsTrue(objFileInfo.Exists); WebInstallerTest.EnumerateProperties(sAppPath); Memba.Tests.Memba_Install_WebInstallerAccessor.Switch404Page(Constants.VirtualDir, sSite, objFileInfo.DirectoryName); WebInstallerTest.EnumerateProperties(sAppPath); DirectoryEntry objApplication = new DirectoryEntry(sAppPath); if (objApplication.Properties[ERRORS].Value is Array) { Array arrErrors = (Array)objApplication.Properties[ERRORS].Value; bool bFound = false; string sRollback = String.Empty; int iRollback = -1; string s404 = String.Empty; for (int iPos = 0; iPos < arrErrors.Length; iPos++) { if ((arrErrors.GetValue(iPos) != null) && ((string)arrErrors.GetValue(iPos)).StartsWith("401")) { sRollback = (string)arrErrors.GetValue(iPos); sRollback = sRollback.Replace("401", "404"); } if ((arrErrors.GetValue(iPos) != null) && ((string)arrErrors.GetValue(iPos)).StartsWith("404")) { //Assuming there is only one s404 = (string)arrErrors.GetValue(iPos); iRollback = iPos; bFound = true; break; } } if ((bFound) && (iRollback > -1) && (!String.IsNullOrEmpty(sRollback))) { objApplication.Properties[ERRORS].RemoveAt(iRollback); objApplication.Properties[ERRORS].Insert(iRollback, sRollback); objApplication.CommitChanges(); Assert.IsTrue(s404.Contains(objFileInfo.FullName)); } else { Assert.Fail("404 Error page not found"); } } objApplication.Close(); }
public void MapDatExtensionToAspNetTest() { const string MAPS = "ScriptMaps"; string sAppPath = Memba.Tests.Memba_Install_WebInstallerAccessor.W3SVC + "/" + Constants.ServerNum + "/ROOT/" + Constants.VirtualDir; string sSite = Memba.Tests.Memba_Install_WebInstallerAccessor.METABASEROOT + Constants.ServerNum; WebInstallerTest.EnumerateProperties(sAppPath); Memba.Tests.Memba_Install_WebInstallerAccessor.MapDatExtensionToAspNet(Constants.VirtualDir, sSite); WebInstallerTest.EnumerateProperties(sAppPath); //Note: it may have been preferrable to use System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() string sDatMapping = ".dat," + Environment.GetEnvironmentVariable("windir") + @"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD"; string sDatMapping64 = ".dat," + Environment.GetEnvironmentVariable("windir") + @"\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD"; DirectoryEntry objApplication = new DirectoryEntry(sAppPath); objApplication.RefreshCache(); int iPos = objApplication.Properties[MAPS].IndexOf(sDatMapping); if (iPos < 0) { Assert.Fail("Mapping not found"); } else { objApplication.Properties[MAPS].RemoveAt(iPos); //Rollback } if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") != "x86") //i.e. AMD64 or I64. Note that 32-bit OS installed on 64-bit processor returns x86 { iPos = objApplication.Properties[MAPS].IndexOf(sDatMapping64); if (iPos < 0) { Assert.Fail("Mapping 64 not found"); } else { objApplication.Properties[MAPS].RemoveAt(iPos); //Rollback } } objApplication.CommitChanges(); objApplication.Close(); Assert.IsTrue(true); //Success }
public void RegisterASPNET2Test() { const string MAPS = "ScriptMaps"; string sSite = Memba.Tests.Memba_Install_WebInstallerAccessor.METABASEROOT + Constants.ServerNum; string sAppPath = Memba.Tests.Memba_Install_WebInstallerAccessor.W3SVC + "/" + Constants.ServerNum + "/ROOT/" + Constants.VirtualDir; WebInstallerTest.EnumerateProperties(sAppPath); Memba.Tests.Memba_Install_WebInstallerAccessor.RegisterASPNET2(Constants.VirtualDir, sSite); WebInstallerTest.EnumerateProperties(sAppPath); DirectoryEntry objApplication = new DirectoryEntry(sAppPath); objApplication.RefreshCache(); //Maybe it would be preferrable to use System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory() string sAspNetMapping = ".aspx," + Environment.GetEnvironmentVariable("windir") + @"\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG"; string sAspNetMapping64 = ".aspx," + Environment.GetEnvironmentVariable("windir") + @"\Microsoft.NET\Framework64\v2.0.50727\aspnet_isapi.dll,1,GET,HEAD,POST,DEBUG"; int iPos = objApplication.Properties[MAPS].IndexOf(sAspNetMapping); if (iPos < 0) { Assert.Fail(".NET 2.0 not installed on " + sAppPath); } if (Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE") != "x86") //i.e. AMD64 or I64. Note that 32-bit OS installed on 64-bit processor returns x86 { iPos = objApplication.Properties[MAPS].IndexOf(sAspNetMapping64); if (iPos < 0) { Assert.Fail("Mapping 64 not found"); } } objApplication.CommitChanges(); objApplication.Close(); Assert.IsTrue(true); //Success }