public void AuthenticateUserCanLoadModulesAccordingToHisRoles() { IPrincipal cachedPrincipal = Thread.CurrentPrincipal; using (TestResourceFile resFile = new TestResourceFile(@"Services\FileCatalogReaderServiceFixtureWithRoles.xml")) { try { GenericIdentity identity = new GenericIdentity("Me"); GenericPrincipal principal = new GenericPrincipal(identity, new string[] { "Users" }); Thread.CurrentPrincipal = principal; SolutionProfileReader slnReader = new SolutionProfileReader(@"Services\FileCatalogReaderServiceFixtureWithRoles.xml"); SolutionProfileElement profile = slnReader.ReadProfile(); Assert.AreEqual(3, profile.Modules.Length, "The solution profile does not contains 3 modules."); Assert.AreEqual("MyAssembly1.dll", profile.Modules[0].AssemblyFile, "The 1st module is not MyAssembly1.dll"); Assert.AreEqual("MyAssembly2.dll", profile.Modules[1].AssemblyFile, "The 2nd module is not MyAssembly2.dll"); Assert.AreEqual("MyAssembly4.dll", profile.Modules[2].AssemblyFile, "The 3rd module is not MyAssembly4.dll"); } finally { Thread.CurrentPrincipal = cachedPrincipal; } } }
public void UnAuthenticatedUserCanLoadModulesWithoutRoles() { IPrincipal originalPrincipal = null; using (TestResourceFile resFile1 = new TestResourceFile(@"Services\FileCatalogReaderServiceFixtureWithRoles.xml")) { try { originalPrincipal = Thread.CurrentPrincipal; if (Thread.CurrentPrincipal.Identity.IsAuthenticated) { Thread.CurrentPrincipal = new GenericPrincipal(WindowsIdentity.GetCurrent(), null); } SolutionProfileReader slnReader = new SolutionProfileReader(@"Services\FileCatalogReaderServiceFixtureWithRoles.xml"); SolutionProfileElement profile = slnReader.ReadProfile(); Assert.AreEqual(1, profile.Modules.Length, "The solution profile does not contains 1 module."); Assert.AreEqual("MyAssembly1.dll", profile.Modules[0].AssemblyFile, "The 1st module is not MyAssembly1.dll"); } finally { Thread.CurrentPrincipal = originalPrincipal; } } }
public void CanLoadProfileContainingModuleWithoutUpdateLocation() { using (TestResourceFile resFile = new TestResourceFile(@"Services\FileCatalogReaderServiceFixtureModuleWithoutUpdateLocation.xml")) { SolutionProfileReader slnReader = new SolutionProfileReader(@"Services\FileCatalogReaderServiceFixtureModuleWithoutUpdateLocation.xml"); SolutionProfileElement profile = slnReader.ReadProfile(); } }
public void ThrowsIfBadFormedFile() { string filename = fileHelper.CreateTempFile(); File.WriteAllText(filename, "<blah />"); SolutionProfileReader slnReader = new SolutionProfileReader(filename); slnReader.ReadProfile(); }
public void DoesNothingIfNoCatalogIsProvidedAndDefaultOneNotExists() { SolutionProfileReader slnReader = new SolutionProfileReader(); SolutionProfileElement profile = slnReader.ReadProfile(); //An empty solutionprofile is returned. Assert.IsNotNull(profile); Assert.IsNotNull(profile.Modules); Assert.AreEqual(0, profile.Modules.Length); }
/// <summary> /// Processes the solution profile and returns the list of modules specified in it. /// </summary> /// <returns>An array of <see cref="Configuration.ModuleInfo"/> instances.</returns> public IModuleInfo[] EnumerateModules() { try { SolutionProfileReader reader = new SolutionProfileReader(catalogFilePath); SolutionProfileElement profile = reader.ReadProfile(); return(CreateModuleInfos(profile)); } catch (Exception ex) { throw new ModuleEnumeratorException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.ErrorEnumeratingModules, this), ex); } }
public void ThrowsIfFileNotFound() { SolutionProfileReader slnReader = new SolutionProfileReader("NonExistingFile.xml"); slnReader.ReadProfile(); }
/// <summary> /// Processes the solution profile and returns the list of modules specified in it. /// </summary> /// <returns>An array of <see cref="Configuration.ModuleInfo"/> instances.</returns> public IModuleInfo[] EnumerateModules() { try { SolutionProfileReader reader = new SolutionProfileReader(catalogFilePath); SolutionProfileElement profile = reader.ReadProfile(); return CreateModuleInfos(profile); } catch (Exception ex) { throw new ModuleEnumeratorException(String.Format(CultureInfo.CurrentCulture, Properties.Resources.ErrorEnumeratingModules, this), ex); } }