示例#1
0
        public void TestInputEmptyTypesAndPlatform()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;

            string commandLine = sgen.CommandLine();

            Assert.True(String.Equals(commandLine, "/assembly:\"C:\\SomeFolder\\MyAsm.dll\\MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\"", StringComparison.OrdinalIgnoreCase));
        }
示例#2
0
        public void TestInputTypes()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.Types                    = new string[] { "System.String", "System.Boolean" };
            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;

            string commandLine = sgen.CommandLine();

            Assert.True(String.Equals(commandLine, "/assembly:\"C:\\SomeFolder\\MyAsm.dll\\MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" /type:System.String /type:System.Boolean", StringComparison.OrdinalIgnoreCase));
        }
示例#3
0
        public void TestKeepFlagFalse()
        {
            SGenExtension sgen = new SGenExtension();
            sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes = false;
            sgen.UseKeep = false;

            string commandLine = sgen.CommandLine();

            Assert.IsTrue(commandLine.IndexOf("/keep", StringComparison.OrdinalIgnoreCase) < 0);
        }
示例#4
0
        public void TestKeepFlagFalse()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes            = false;
            sgen.UseKeep = false;

            string commandLine = sgen.CommandLine();

            Assert.True(commandLine.IndexOf("/keep", StringComparison.OrdinalIgnoreCase) < 0);
        }
示例#5
0
        public void TestInputChecks3()
        {
            MockEngine    engine = new MockEngine();
            SGenExtension sgen   = new SGenExtension();

            sgen.BuildEngine              = engine;
            sgen.BuildAssemblyName        = null;
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes            = false;
            // This should result in a quoted parameter...
            sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";
            string commandLine = sgen.CommandLine();
        }
示例#6
0
 public void TestInputChecks1()
 {
     MockEngine engine = new MockEngine();
     SGenExtension sgen = new SGenExtension();
     sgen.BuildEngine = engine;
     sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" + Path.GetInvalidPathChars()[0];
     sgen.BuildAssemblyPath = "C:\\SomeFolder\\MyAsm.dll";
     sgen.ShouldGenerateSerializer = true;
     sgen.UseProxyTypes = false;
     // This should result in a quoted parameter...
     sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";
     string commandLine = sgen.CommandLine();
     Assert.IsTrue(engine.Errors == 1);
 }
示例#7
0
        public void TestInputEmptyTypesAndPlatform()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = NativeMethodsShared.IsUnixLike ? "/SomeFolder/MyAsm.dll" : "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;

            string commandLine       = sgen.CommandLine();
            string targetCommandLine = "/assembly:\"" + sgen.BuildAssemblyPath + Path.DirectorySeparatorChar
                                       + "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\"";

            Assert.Equal(targetCommandLine, commandLine);
        }
示例#8
0
        public void TestInputChecks2()
        {
            MockEngine    engine = new MockEngine();
            SGenExtension sgen   = new SGenExtension();

            sgen.BuildEngine              = engine;
            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll" + Path.GetInvalidPathChars()[0];
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes            = false;
            // This should result in a quoted parameter...
            sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";
            string commandLine = sgen.CommandLine();

            Assert.Equal(1, engine.Errors);
        }
示例#9
0
        public void TestInputTypes()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.Types             = new string[] { "System.String", "System.Boolean" };
            sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath = NativeMethodsShared.IsUnixLike
                                         ? "/SomeFolder/MyAsm.dll"
                                         : "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;

            string commandLine       = sgen.CommandLine();
            string targetCommandLine = "/assembly:\"" + sgen.BuildAssemblyPath + Path.DirectorySeparatorChar
                                       + "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" /type:System.String /type:System.Boolean";

            Assert.True(String.Equals(commandLine, targetCommandLine, StringComparison.OrdinalIgnoreCase));
        }
示例#10
0
        public void TestReferencesCommandLine()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes            = false;
            sgen.UseKeep    = false;
            sgen.References = new string[] { "C:\\SomeFolder\\reference1.dll", "C:\\SomeFolder\\reference2.dll" };

            string commandLine       = sgen.CommandLine();
            string targetCommandLine = "/assembly:\"" + sgen.BuildAssemblyPath + Path.DirectorySeparatorChar
                                       + "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" /reference:\"C:\\SomeFolder\\reference1.dll,C:\\SomeFolder\\reference2.dll\"";

            Assert.Equal(targetCommandLine, commandLine);
        }
示例#11
0
        public void TestInputChecks4()
        {
            Assert.Throws <ArgumentNullException>(() =>
            {
                MockEngine engine             = new MockEngine();
                SGenExtension sgen            = new SGenExtension();
                sgen.BuildEngine              = engine;
                sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                sgen.BuildAssemblyPath        = null;
                sgen.ShouldGenerateSerializer = true;
                sgen.UseProxyTypes            = false;
                // This should result in a quoted parameter...
                sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";

                string commandLine = sgen.CommandLine();
            }
                                                  );
        }
示例#12
0
        public void KeyFileQuotedOnCommandLineIfNecessary()
        {
            SGenExtension sgen = new SGenExtension();
            sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes = false;

            // This should result in a nested, quoted parameter on
            // the command line, which ultimately looks like this:
            //
            //   /compiler:"/keyfile:\"c:\Some Folder\MyKeyFile.snk\""
            //
            sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";

            string commandLine = sgen.CommandLine();

            Assert.IsTrue(commandLine.IndexOf("/compiler:\"/keyfile:\\\"" + sgen.KeyFile + "\\\"\"", StringComparison.OrdinalIgnoreCase) >= 0);
        }
示例#13
0
        public void KeyFileQuotedOnCommandLineIfNecessary()
        {
            SGenExtension sgen = new SGenExtension();

            sgen.BuildAssemblyName        = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath        = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;
            sgen.UseProxyTypes            = false;

            // This should result in a nested, quoted parameter on
            // the command line, which ultimately looks like this:
            //
            //   /compiler:"/keyfile:\"c:\Some Folder\MyKeyFile.snk\""
            //
            sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";

            string commandLine = sgen.CommandLine();

            Assert.True(commandLine.IndexOf("/compiler:\"/keyfile:\\\"" + sgen.KeyFile + "\\\"\"", StringComparison.OrdinalIgnoreCase) >= 0);
        }
示例#14
0
 public void TestInputChecks3()
 {
     MockEngine engine = new MockEngine();
     SGenExtension sgen = new SGenExtension();
     sgen.BuildEngine = engine;
     sgen.BuildAssemblyName = null;
     sgen.BuildAssemblyPath = "C:\\SomeFolder\\MyAsm.dll";
     sgen.ShouldGenerateSerializer = true;
     sgen.UseProxyTypes = false;
     // This should result in a quoted parameter...
     sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";
     string commandLine = sgen.CommandLine();
 }
示例#15
0
        public void TestInputTypes()
        {
            SGenExtension sgen = new SGenExtension();
            sgen.Types = new string[] { "System.String", "System.Boolean" };
            sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;

            string commandLine = sgen.CommandLine();

            Assert.IsTrue(String.Equals(commandLine, "/assembly:\"C:\\SomeFolder\\MyAsm.dll\\MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\" /type:System.String /type:System.Boolean", StringComparison.OrdinalIgnoreCase));
        }
示例#16
0
        public void TestInputChecks4()
        {
            Assert.Throws<ArgumentNullException>(() =>
            {
                MockEngine engine = new MockEngine();
                SGenExtension sgen = new SGenExtension();
                sgen.BuildEngine = engine;
                sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
                sgen.BuildAssemblyPath = null;
                sgen.ShouldGenerateSerializer = true;
                sgen.UseProxyTypes = false;
                // This should result in a quoted parameter...
                sgen.KeyFile = "c:\\Some Folder\\MyKeyFile.snk";

                string commandLine = sgen.CommandLine();
            }
           );
        }
示例#17
0
        public void TestInputEmptyTypesAndPlatform()
        {
            SGenExtension sgen = new SGenExtension();
            sgen.BuildAssemblyName = "MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";
            sgen.BuildAssemblyPath = "C:\\SomeFolder\\MyAsm.dll";
            sgen.ShouldGenerateSerializer = true;

            string commandLine = sgen.CommandLine();

            Assert.IsTrue(String.Equals(commandLine, "/assembly:\"C:\\SomeFolder\\MyAsm.dll\\MyAsm, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\"", StringComparison.OrdinalIgnoreCase));
        }