public void TestFromStringWithInvalidValue() { try { ProgrammingLanguageHelper.FromString("Invalid value"); } catch { return; } Assert.Fail(); }
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)); } }
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)); } }
public void TestFromStringWithCorrectValue() { Assert.AreEqual(ProgrammingLanguage.C, ProgrammingLanguageHelper.FromString("C")); }