コード例 #1
0
        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;
                }
            }
        }
コード例 #2
0
        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;
                }
            }
        }
コード例 #3
0
 public void CanLoadProfileContainingModuleWithoutUpdateLocation()
 {
     using (TestResourceFile resFile = new TestResourceFile(@"Services\FileCatalogReaderServiceFixtureModuleWithoutUpdateLocation.xml"))
     {
         SolutionProfileReader slnReader =
             new SolutionProfileReader(@"Services\FileCatalogReaderServiceFixtureModuleWithoutUpdateLocation.xml");
         SolutionProfileElement profile = slnReader.ReadProfile();
     }
 }
コード例 #4
0
        public void ThrowsIfBadFormedFile()
        {
            string filename = fileHelper.CreateTempFile();

            File.WriteAllText(filename, "<blah />");
            SolutionProfileReader slnReader = new SolutionProfileReader(filename);

            slnReader.ReadProfile();
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 /// <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);
     }
 }
コード例 #7
0
        public void ThrowsIfFileNotFound()
        {
            SolutionProfileReader slnReader = new SolutionProfileReader("NonExistingFile.xml");

            slnReader.ReadProfile();
        }
コード例 #8
0
 /// <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);
     }
 }