예제 #1
0
 public void TestFromStringWithInvalidValue()
 {
     try
     {
         ProgrammingLanguageHelper.FromString("Invalid value");
     }
     catch
     {
         return;
     }
     Assert.Fail();
 }
예제 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Type your name:");
            var usename = Console.ReadLine();

            Console.WriteLine("Type your password:"******"ProblemNo:");
                int problemNo;
                while (!int.TryParse(Console.ReadLine(), out problemNo))
                {
                    Console.WriteLine("ProblemNo must be integer");
                }

                Console.WriteLine("Language:");
                ProgrammingLanguage language;
                while (true)
                {
                    var l = Console.ReadLine();
                    try
                    {
                        language = ProgrammingLanguageHelper.FromString(l);
                        break;
                    }
                    catch (ArgumentException)
                    {
                        Console.WriteLine("Invalid Language. Prease type again");
                    }
                }

                Console.WriteLine("Source code:");
                StringBuilder sb = new StringBuilder();
                while (true)
                {
                    var c = Console.Read();
                    if (c == -1)
                    {
                        break;
                    }
                    sb.Append((char)c);
                }

                var rid = client.Submit(problemNo, language, sb.ToString());
                Console.WriteLine("Openning Browser...");
                System.Diagnostics.Process.Start(string.Format("http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid={0}#1", rid));
            }
        }
예제 #3
0
        public void TestFromStringWithSpecialValue()
        {
            var values = new Dictionary <string, ProgrammingLanguage>()
            {
                { "C#", ProgrammingLanguage.Csharp },
                { "js", ProgrammingLanguage.JavaScript },
            };

            foreach (var t in values)
            {
                Assert.AreEqual(t.Value, ProgrammingLanguageHelper.FromString(t.Key));
            }
        }
예제 #4
0
 public void TestFromStringWithCorrectValue()
 {
     Assert.AreEqual(ProgrammingLanguage.C, ProgrammingLanguageHelper.FromString("C"));
 }