static void Main(string[] args) { Console.WriteLine("================ START ===================="); CommandLineParams commandLine = CommandLineParams.Parse(args); bool IsElevated = false; using (var id = WindowsIdentity.GetCurrent()) { IsElevated = (id.Owner != id.User); var userName = id.Name; var isSystem = "IsSystem=" + id.IsSystem; var isElevated = "IsElevated=" + IsElevated; Console.Title = string.Join("; ", userName, isElevated, isSystem); Console.WriteLine("UserName: "******"Owner SID: " + id.Owner); Console.WriteLine("User SID: " + id.User); Console.WriteLine("Groups: ----------------------------------"); foreach (var group in id.Groups) { Console.WriteLine(group.Value); } Console.WriteLine("----------------------------------"); } bool needRestart = false; if (IsElevated) { needRestart = !commandLine.NoRestart; } if (needRestart) { RunElevated(); } else { Task.Run(() => { StartTest(); }); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } //Console.WriteLine("Press any key to exit..."); //Console.ReadKey(); Console.WriteLine("================ THE END ==================="); }
public void CanSetMainParams2() { var p = CommandLineParams.Parse(new[] { "111", "moo-test", "ECM7.Migrator.TestAssembly.dll" }); Assert.AreEqual("111", p.config.Provider); Assert.AreEqual("moo-test", p.config.ConnectionStringName); Assert.AreEqual("ECM7.Migrator.TestAssembly.dll", p.config.AssemblyFile); Assert.IsNull(p.config.ConnectionString); Assert.IsNull(p.config.Assembly); }
public void CanSetMainParams1() { var p = CommandLineParams.Parse(new[] { "111", "222", "333" }); Assert.AreEqual("111", p.config.Provider); Assert.AreEqual("222", p.config.ConnectionString); Assert.AreEqual("333", p.config.Assembly); Assert.IsNull(p.config.ConnectionStringName); Assert.IsNull(p.config.AssemblyFile); }
public void CanSetAdditionalOptions2() { var p = CommandLineParams.Parse(new[] { "111", "moo-test", "ECM7.Migrator.TestAssembly.dll", @"/?" }); Assert.AreEqual(-1, p.version); Assert.AreEqual(MigratorConsoleMode.Help, p.mode); }
public void CanSetAdditionalOptions() { var p = CommandLineParams.Parse(new[] { "111", "moo-test", "ECM7.Migrator.TestAssembly.dll", "-v:123", "-list" }); Assert.AreEqual(123, p.version); Assert.AreEqual(MigratorConsoleMode.List, p.mode); }
public void NotEnoughtParametersMustSetHelpMode() { var p = CommandLineParams.Parse(new[] { "111" }); Assert.AreEqual(MigratorConsoleMode.Help, p.mode); }