コード例 #1
0
        public void ShouldReturnNullProblemsWithEmptyModule()
        {
            MockConfigurationIntrospectionRule rule = new MockConfigurationIntrospectionRule();
            ProblemCollection problems = rule.Check(ModuleNode.GetModule(Assembly.GetExecutingAssembly().Location));

            Assert.IsNull(problems);
        }
コード例 #2
0
ファイル: ChelaCompiler.cs プロジェクト: MilkTool/chela
        public void LoadReference(string filename)
        {
            // Load the referenced module.
            ChelaModule module = ChelaModule.LoadNamedModule(filename);

            // Add the reference.
            moduleNode.GetModule().AddReference(module);
        }
コード例 #3
0
        public void ShouldReturnNullProblemsWithBadWcfConfigurationFile()
        {
            MockServiceModelConfigurationRule rule = new MockServiceModelConfigurationRule();

            using (var module = ModuleNode.GetModule(GetAsmLocation("BadConfigFile")))
            {
                ProblemCollection problems = rule.Check(module);
                Assert.IsNull(problems);
            }
        }
コード例 #4
0
        public void ShouldGetSixProblemsWithConfigFile()
        {
            Configuration configuration             = ConfigurationLoader.LoadConfiguration("BindingNotSupportedSession.config", "TestConfigs");
            ContractBindingNotSupportedSession rule = new ContractBindingNotSupportedSession();

            rule.Check(configuration);
            using (ModuleNode module = ModuleNode.GetModule(
                       typeof(ContractBindingNotSupportedSessionFixture).Assembly.Location, true, true, true))
            {
                rule.Check(module);
            }

            Assert.AreEqual(6, rule.Problems.Count);
        }
コード例 #5
0
        public void ShouldGetTheSourceFile()
        {
            MockConfigurationIntrospectionRule rule = new MockConfigurationIntrospectionRule();
            string configPath = CreateConfigurationFile("EmptyConfigFile.config", null);

            using (var module = ModuleNode.GetModule(GetAsmLocation("EmptyConfigFile", null)))
            {
                rule.Check(module);
                if (!rule.IsConfigInTempPath())
                {
                    Assert.AreEqual(configPath, rule.SourceFile);
                }
                Assert.IsNotNull(rule.Configuration);
            }
        }
コード例 #6
0
        public override AstNode Visit(ModuleNode node)
        {
            // Store the old module.
            ChelaModule oldModule = this.currentModule;

            currentModule = node.GetModule();

            // Visit the children.
            PushScope(currentModule.GetGlobalNamespace());
            VisitList(node.GetChildren());
            PopScope();

            // Restore the module.
            currentModule = oldModule;
            return(node);
        }
コード例 #7
0
        public void ShouldGetTheConfigurationFromWebConfigFile()
        {
            MockConfigurationIntrospectionRule rule = new MockConfigurationIntrospectionRule();
            // create a separate folder to test the web config file
            DirectoryInfo webDir = Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WebConfigTest"));
            // put there the web config file
            string configPath = CreateConfigurationFile("EmptyConfigFile.config", Path.Combine(webDir.FullName, "web.config"));
            // put the asm in a subdirectory of web config dir
            DirectoryInfo asmDir = webDir.CreateSubdirectory("Asm");

            using (var module =
                       ModuleNode.GetModule(GetAsmLocation("EmptyConfigFile", Path.Combine(asmDir.FullName, Path.GetFileName(Assembly.GetExecutingAssembly().Location)))))
            {
                rule.Check(module);
                Assert.AreEqual(configPath, rule.SourceFile);
                Assert.IsNotNull(rule.Configuration);
            }
        }
コード例 #8
0
 private static TypeNode FileGetType(ModuleNode module, Identifier nameSpace, Identifier name)
 {
     foreach (string file in Directory.GetFiles(
                  module.Directory, "*.dll", SearchOption.TopDirectoryOnly))
     {
         if (file != module.Location)
         {
             ModuleNode localModule = ModuleNode.GetModule(file, true, false, true);
             if (localModule != null)
             {
                 TypeNode typeNode = localModule.GetType(nameSpace, name);
                 if (typeNode != null)
                 {
                     // resolve any assembly reference not loaded (GACed)
                     localModule.AssemblyReferenceResolutionAfterProbingFailed +=
                         new ModuleNode.AssemblyReferenceResolver(OnAssemblyReferenceResolutionAfterProbingFailed);
                     return(typeNode);
                 }
                 localModule.Dispose();
             }
         }
     }
     return(null);
 }