コード例 #1
0
        public void TestIdlFilesReadFromFile()
        {
            string fileWithIdlFiles = Path.GetTempFileName();

            try
            {
                string file1 = "test1.idl";
                string file2 = "test2.idl";
                using (StreamWriter sw = new StreamWriter(fileWithIdlFiles))
                {
                    sw.WriteLine(file1);
                    sw.WriteLine(file2);
                }

                IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                    new string[] { "-fidl:" + fileWithIdlFiles, "testAsm" });
                Assert.AreEqual(2,
                                commandLine.InputFileNames.Count, "idl files");
                Assert.AreEqual(file1,
                                commandLine.InputFileNames[0], "idl file1");
                Assert.AreEqual(
                    file2,
                    commandLine.InputFileNames[1], "idl file2");

                Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
            }
            finally
            {
                if (File.Exists(fileWithIdlFiles))
                {
                    File.Delete(fileWithIdlFiles);
                }
            }
        }
コード例 #2
0
        public void TestRefAssembliesInvalid()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-r", "inexistientAssembly.dll", "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.IsInvalid, "Command line validity");
            Assert.IsTrue(commandLine.ErrorMessage.StartsWith("can't load assembly: inexistientAssembly.dll"), "invalid arguments message");
        }
コード例 #3
0
        public void TestMissingIdlFileName()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "testAsm" });

            Assert.IsTrue(commandLine.IsInvalid, "Invalid commandLine detection");
            Assert.AreEqual("Error: idl-file(s) missing",
                            commandLine.ErrorMessage, "invalid commandLine message");
        }
コード例 #4
0
        public void TestMissingTargetAssemblyName()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[0]);

            Assert.IsTrue(commandLine.IsInvalid, "Invalid commandLine detection");
            Assert.AreEqual("Error: target assembly name missing",
                            commandLine.ErrorMessage, "invalid commandLine message");
        }
コード例 #5
0
        public void TestWrongArgument()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-InvalidArg" });

            Assert.IsTrue(commandLine.IsInvalid, "Invalid Arg detection");
            Assert.AreEqual("Error: invalid option -InvalidArg",
                            commandLine.ErrorMessage, "invalid arguments message");
        }
コード例 #6
0
        public void TestVtSkelOverwrite()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-vtSkelO", "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.OverwriteValueTypeSkeletons, "Value Type Skeleton overwrite");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #7
0
        public void TestDelaySign()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-delaySign", "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.DelaySign, "DelaySign");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #8
0
        public void TestMapToAnyContainer()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-mapAnyToCont", "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.MapAnyToAnyContainer, "Map any to any container");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #9
0
        public void TestVtSkel()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-vtSkel", "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.GenerateValueTypeSkeletons, "Value Type Skeleton generation");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #10
0
        public void TestTargetAssemblyName()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "testAsm", "test.idl" });

            Assert.AreEqual("testAsm", commandLine.TargetAssemblyName, "targetAssemblyName");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #11
0
        public void TestVtGenerationProvider()
        {
            Type   provider                 = typeof(Microsoft.CSharp.CSharpCodeProvider);
            string providerName             = provider.AssemblyQualifiedName;
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-vtSkelProv", providerName, "testAsm", "test.idl" });

            Assert.IsTrue(!commandLine.IsInvalid, "Command Line Validity");
            Assert.AreEqual(provider, commandLine.ValueTypeSkeletonCodeDomProviderType, "Valuetype Skeletons Generation Provider");
        }
コード例 #12
0
        public void TestBaseInterfaceNonExisting()
        {
            string baseInterfaceName        = "System.IDisposableNonExisting";
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-b", baseInterfaceName, "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.IsInvalid, "Invalid base interface");
            Assert.AreEqual(string.Format("Error: base interface {0} does not exist!", baseInterfaceName),
                            commandLine.ErrorMessage, "invalid arguments message");
        }
コード例 #13
0
        public void TestInheritBaseInterface()
        {
            Type type = typeof(IDisposable);
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-b", type.FullName, "testAsm", "test.idl" });

            Assert.AreEqual(type.FullName, commandLine.BaseInterface.FullName, "BaseInterface");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #14
0
        public void TestVtGenerationProviderInvalid()
        {
            string providerName             = "System.NonExistingProvider";
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-vtSkelProv", providerName, "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.IsInvalid, "Invalid codedom provider");
            Assert.AreEqual(string.Format("provider {0} not found!", providerName),
                            commandLine.ErrorMessage, "invalid arguments message");
        }
コード例 #15
0
        public void TestBaseDirectory()
        {
            DirectoryInfo       testDir     = new DirectoryInfo(".");
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-basedir", testDir.FullName, "testAsm", "test.idl" });

            Assert.AreEqual(testDir.FullName, commandLine.BaseDirectory.FullName, "BaseDirectory");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #16
0
        public void TestBaseDirectoryNonExisting()
        {
            DirectoryInfo       testDir     = new DirectoryInfo(Path.Combine(".", "NonExistantBaseDir"));
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-basedir", testDir.FullName, "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.IsInvalid, "Invalid Base directory");
            Assert.AreEqual(string.Format("Error: base directory {0} does not exist!", testDir.FullName),
                            commandLine.ErrorMessage, "invalid arguments message");
        }
コード例 #17
0
        public void TestAsmVersion()
        {
            string asmVersion = "1.0.0.0";
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-asmVersion", asmVersion, "testAsm", "test.idl" });

            Assert.AreEqual(asmVersion, commandLine.AssemblyVersion, "Target Assembly Version");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #18
0
        public void TestSnkFile()
        {
            string snkFile = "test.snk";
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-snk", snkFile, "testAsm", "test.idl" });

            Assert.AreEqual(snkFile, commandLine.SignKeyFile.Name, "Key file");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #19
0
        public void TestDefaultOutputDir()
        {
            DirectoryInfo       testDir     = new DirectoryInfo(".");
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "testAsm", "test.idl" });

            Assert.AreEqual(testDir.FullName,
                            commandLine.OutputDirectory.FullName, "OutputDirectory");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #20
0
        public void TestOutDirColonSeparator()
        {
            DirectoryInfo       testDir     = new DirectoryInfo(Path.Combine(".", "testOut"));
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-out:" + testDir.FullName, "testAsm", "test.idl" });

            Assert.AreEqual(testDir.FullName,
                            commandLine.OutputDirectory.FullName, "OutputDirectory");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #21
0
        public void TestVtTargetDir()
        {
            DirectoryInfo       testDir     = new DirectoryInfo(Path.Combine(".", "testGenVtDir"));
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-vtSkelTd", testDir.FullName, "testAsm", "test.idl" });

            Assert.AreEqual(testDir.FullName, commandLine.ValueTypeSkeletonsTargetDir.FullName,
                            "Valuetype Skeletons Target Directory");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #22
0
        public void TestIsHelpRequested()
        {
            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-h" });

            Assert.IsTrue(commandLine.IsHelpRequested, "Help requested");
            commandLine = new IDLToCLSCommandLine(
                new string[] { "-help" });
            Assert.IsTrue(commandLine.IsHelpRequested, "Help requested");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #23
0
        public void TestCustomMappingFilesMultipleTheSame()
        {
            string customMappingFile1 = "customMapping1.xml";
            string customMappingFile2 = "customMapping1.xml";

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-c", customMappingFile1, "-c", customMappingFile2,
                               "testAsm", "test.idl" });

            Assert.IsTrue(commandLine.IsInvalid, "Invalid commandLine detection");
            Assert.IsTrue(commandLine.ErrorMessage.StartsWith(
                              "tried to add a custom mapping file multiple times: "), "invalid commandLine message");
        }
コード例 #24
0
        public void TestSingleIdlFile()
        {
            string file1 = "test1.idl";

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "testAsm", file1 });

            Assert.AreEqual(1,
                            commandLine.InputFileNames.Count, "idl files");
            Assert.AreEqual(file1, commandLine.InputFileNames[0], "idl file1");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #25
0
        public void TestPreprocessorDefines()
        {
            string def1 = "def1";
            string def2 = "def2";

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-d", def1, "-d", def2, "testAsm", "test.idl" });

            Assert.AreEqual(2,
                            commandLine.PreprocessorDefines.Count, "defines");
            Assert.AreEqual(def1,
                            commandLine.PreprocessorDefines[0], "define 1");
            Assert.AreEqual(def2,
                            commandLine.PreprocessorDefines[1], "define 2");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #26
0
        public void TestCustomMappingFiles()
        {
            string customMappingFile1 = "customMapping1.xml";
            string customMappingFile2 = "customMapping2.xml";

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-c", customMappingFile1, "-c", customMappingFile2,
                               "testAsm", "test.idl" });

            Assert.AreEqual(2,
                            commandLine.CustomMappingFiles.Count, "CustomMappingFiles");
            Assert.AreEqual(customMappingFile1,
                            ((FileInfo)commandLine.CustomMappingFiles[0]).Name, "CustomMappingFile 1");
            Assert.AreEqual(customMappingFile2,
                            ((FileInfo)commandLine.CustomMappingFiles[1]).Name, "CustomMappingFile 2");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #27
0
        public void TestIdlSourceDirectories()
        {
            DirectoryInfo dir1 = new DirectoryInfo(".");
            DirectoryInfo dir2 = new DirectoryInfo(Path.Combine(".", "testIdlDir"));

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-idir", dir1.FullName, "-idir", dir2.FullName, "testAsm", "test.idl" });

            Assert.AreEqual(2,
                            commandLine.IdlSourceDirectories.Count, "idl source dirs");
            Assert.AreEqual(dir1.FullName,
                            ((DirectoryInfo)commandLine.IdlSourceDirectories[0]).FullName,
                            "idl source dir 1");
            Assert.AreEqual(dir2.FullName,
                            ((DirectoryInfo)commandLine.IdlSourceDirectories[1]).FullName,
                            "idl source dir 2");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #28
0
        public void TestRefAssembliesColonSeparator()
        {
            Assembly asm1 = this.GetType().Assembly;
            Assembly asm2 = typeof(TestAttribute).Assembly;

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-r:" + asm1.CodeBase, "-r:" + asm2.CodeBase, "testAsm", "test.idl" });

            Assert.AreEqual(2,
                            commandLine.ReferencedAssemblies.Count, "referenced assemblies");
            Assert.AreEqual(asm1.FullName,
                            ((Assembly)commandLine.ReferencedAssemblies[0]).FullName,
                            "ref assembly 1");
            Assert.AreEqual(asm2.FullName,
                            ((Assembly)commandLine.ReferencedAssemblies[1]).FullName,
                            "ref assembly 2");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #29
0
        public void TestIdlFiles()
        {
            string file1 = "test1.idl";
            string file2 = "test2.idl";
            string file3 = "test3.idl";

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "testAsm", file1, file2, file3 });

            Assert.AreEqual(3,
                            commandLine.InputFileNames.Count, "idl files");
            Assert.AreEqual(file1,
                            commandLine.InputFileNames[0], "idl file1");
            Assert.AreEqual(
                file2,
                commandLine.InputFileNames[1], "idl file2");
            Assert.AreEqual(
                file3,
                commandLine.InputFileNames[2], "idl file3");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }
コード例 #30
0
        public void TestLibDirs()
        {
            DirectoryInfo dir1 = new DirectoryInfo(Path.Combine(".", "lib1"));
            DirectoryInfo dir2 = new DirectoryInfo(Path.Combine(".", "lib2"));
            DirectoryInfo dir3 = new DirectoryInfo(Path.Combine(".", "lib3"));

            IDLToCLSCommandLine commandLine = new IDLToCLSCommandLine(
                new string[] { "-lib:" + dir1.FullName + ";" + dir2.FullName,
                               "-lib:" + dir3.FullName, "testAsm", "test.idl" });

            Assert.AreEqual(3,
                            commandLine.LibDirectories.Count, "libs");
            Assert.AreEqual(dir1.FullName,
                            ((DirectoryInfo)commandLine.LibDirectories[0]).FullName,
                            "lib dir 1");
            Assert.AreEqual(dir2.FullName,
                            ((DirectoryInfo)commandLine.LibDirectories[1]).FullName,
                            "lib dir 2");
            Assert.AreEqual(dir3.FullName,
                            ((DirectoryInfo)commandLine.LibDirectories[2]).FullName,
                            "lib dir 3");

            Assert.IsTrue(!commandLine.IsInvalid, "Command line validity");
        }