コード例 #1
0
 public void OrleansHostParseUsageArg()
 {
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsFalse(prog.ParseArguments(new string[] { "/?" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "-?" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "/help" }));
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: Rejendo/orleans
        static void Main(string[] args)
        {
            RuntimeVersion.ProgamIdent();

            var prog = new WindowsServerHost();
            
            int exitCode;
            try
            {
                if (!prog.ParseArguments(args))
                {
                    prog.PrintUsage();
                    exitCode = -1;
                }
                else
                {
                    if (prog.Debug)
                        DumpCommandLineArgs(args);
                    
                    prog.Init();
                    exitCode = prog.Run();
                }
            }
            catch (Exception exc)
            {
                ConsoleText.WriteError(string.Format("{0} halting due to error - {1}", RuntimeVersion.ProgramName, exc.ToString()));
                exitCode = 1;
            }
            finally
            {
                prog.Dispose();
            }

            Environment.Exit(exitCode);
        }
コード例 #3
0
 public void OrleansHostParseSiloNameArg()
 {
     var expectedSiloName = "MySilo";
     var expectedSiloType = Silo.SiloType.Secondary;
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsTrue(prog.ParseArguments(new string[] { expectedSiloName }));
     Assert.AreEqual(expectedSiloType, prog.SiloHost.Type);
     Assert.AreEqual(expectedSiloName, prog.SiloHost.Name);
 }
コード例 #4
0
 public void OrleansHostParseNoArgs()
 {
     var expectedSiloName = this.hostname;
     var expectedSiloType = Silo.SiloType.Secondary;
     WindowsServerHost prog = new WindowsServerHost();
     Assert.True(prog.ParseArguments(new string[] { }));
     Assert.Equal(expectedSiloType, prog.SiloHost.Type);
     Assert.Equal(expectedSiloName, prog.SiloHost.Name);
 }
コード例 #5
0
 public void OrleansHostParseBadArguments()
 {
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsFalse(prog.ParseArguments(new string[] { "/xyz" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "/xyz", "/abc" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "/xyz", "/abc", "/123" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "/xyz", "/abc", "/123", "/456" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "DeploymentId=" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "DeploymentGroup=" }));
 }
コード例 #6
0
 public void OrleansHostParsePrimarySiloNameArg()
 {
     var expectedSiloName = "Primary";
     var expectedSiloType = Silo.SiloType.Primary;
     WindowsServerHost prog = new WindowsServerHost();
     Assert.True(prog.ParseArguments(new string[] { expectedSiloName }));
     prog.Init();
     Assert.Equal(expectedSiloType, prog.SiloHost.Type);
     Assert.Equal(expectedSiloName, prog.SiloHost.Name);
 }
コード例 #7
0
        static void Main(string[] args)
        {
            RuntimeVersion.ProgamIdent();

            var prog = new WindowsServerHost();

            int exitCode;

            try
            {
                if (!prog.ParseArguments(args))
                {
                    prog.PrintUsage();
                    exitCode = -1;
                }
                else
                {
                    if (prog.Debug)
                    {
                        DumpCommandLineArgs(args);
                    }

                    prog.Init();
                    exitCode = prog.Run();
                }
            }
            catch (Exception exc)
            {
                ConsoleText.WriteError(string.Format("{0} halting due to error - {1}", RuntimeVersion.ProgramName, exc.ToString()));
                exitCode = 1;
            }
            finally
            {
                prog.Dispose();
            }

            Environment.Exit(exitCode);
        }
コード例 #8
0
 public void OrleansHostParseDeploymentIdArg()
 {
     var expectedSiloName = this.hostname;
     var expectedDeploymentId = Guid.NewGuid().ToString("D");
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
     Assert.AreEqual(expectedSiloName, prog.SiloHost.Name);
     Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);
 }
コード例 #9
0
 public void OrleansHostParseUsageArgWithOtherArgs()
 {
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsFalse(prog.ParseArguments(new string[] { "/?", "SiloName", "CfgFile.xml" }));
     Assert.IsFalse(prog.ParseArguments(new string[] { "SiloName", "CfgFile.xml", "/?" }));
 }
コード例 #10
0
 public void OrleansHostParseMultipleArgs()
 {
     var expectedSiloName = "MySilo";
     var expectedConfigFileName = @"OrleansConfiguration.xml";
     var expectedDeploymentId = Guid.NewGuid();
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsTrue(prog.ParseArguments(new string[] { 
         expectedSiloName, 
         expectedConfigFileName, 
         "DeploymentId=" + expectedDeploymentId
     }));
     Assert.AreEqual(expectedSiloName, prog.SiloHost.Name);
     Assert.AreEqual(expectedConfigFileName, prog.SiloHost.ConfigFileName);
     Assert.AreEqual(expectedDeploymentId.ToString(), prog.SiloHost.DeploymentId);
 }
コード例 #11
0
 public void OrleansHostParseDeploymentGroupLastArgWins()
 {
     var expectedDeploymentId1 = Guid.NewGuid();
     var expectedDeploymentId2 = Guid.NewGuid();
     WindowsServerHost prog = new WindowsServerHost();
     Assert.IsTrue(prog.ParseArguments(new string[] { 
         "DeploymentId=" + expectedDeploymentId1,
         "DeploymentId=" + expectedDeploymentId2,
         "DeploymentGroup=" + expectedDeploymentId1,
         "DeploymentGroup=" + expectedDeploymentId2 
     }));
     Assert.AreEqual(expectedDeploymentId2.ToString(), prog.SiloHost.DeploymentId);
 }
コード例 #12
0
        public void OrleansHostParseDeploymentGroupArgFormats()
        {
            var expectedDeploymentId = Guid.NewGuid().ToString("N");
            WindowsServerHost prog = new WindowsServerHost();
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);

            prog = new WindowsServerHost();
            expectedDeploymentId = Guid.NewGuid().ToString("D");
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);

            prog = new WindowsServerHost();
            expectedDeploymentId = Guid.NewGuid().ToString("B");
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);

            prog = new WindowsServerHost();
            expectedDeploymentId = Guid.NewGuid().ToString("P");
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);

            prog = new WindowsServerHost();
            expectedDeploymentId = Guid.NewGuid().ToString("X");
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);

            prog = new WindowsServerHost();
            expectedDeploymentId = Guid.NewGuid().ToString("");
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);

            prog = new WindowsServerHost();
            expectedDeploymentId = Guid.NewGuid().ToString();
            Assert.IsTrue(prog.ParseArguments(new string[] { "DeploymentId=" + expectedDeploymentId }));
            Assert.AreEqual(expectedDeploymentId, prog.SiloHost.DeploymentId);
        }
コード例 #13
0
 public void OrleansHostParseConfigFileArg()
 {
     var expectedSiloName = "MySilo";
     var expectedSiloType = Silo.SiloType.Secondary;
     var expectedConfigFileName = @"OrleansConfiguration.xml";
     WindowsServerHost prog = new WindowsServerHost();
     Assert.True(prog.ParseArguments(new string[] { expectedSiloName, expectedConfigFileName }));
     Assert.Equal(expectedSiloType, prog.SiloHost.Type);
     Assert.Equal(expectedSiloName, prog.SiloHost.Name);
     Assert.Equal(expectedConfigFileName, prog.SiloHost.ConfigFileName);
 }