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)); }
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)); }
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); }
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); }
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(); }
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); }
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); }
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); }
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)); }
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); }
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(); } ); }
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); }
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); }
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)); }
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(); } ); }
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)); }