public void TestCase03() { GiftInvest gi = new GiftInvest(); gi.SetBudget(100); gi.AddOdds(100); gi.AddOdds(1); gi.AddOdds(60); StringBuilder sb = new StringBuilder(); List <int> result = null; try { result = gi.Calculate(); if (result != null) { result.ForEach(x => sb.AppendLine(x.ToString())); } } catch (ImpossibleException e) { sb.Clear(); sb.Append("IMPOSSIBLE"); } StringBuilder ans = new StringBuilder(); ans.AppendLine("1"); ans.AppendLine("49"); ans.AppendLine("50"); Assert.AreEqual(ans.ToString(), sb.ToString()); }
public void TestCase04() { /* * 3 * 100 * 20 * 20 * 20 */ GiftInvest gi = new GiftInvest(); gi.SetBudget(100); gi.AddOdds(20); gi.AddOdds(20); gi.AddOdds(20); StringBuilder sb = new StringBuilder(); List <int> result = null; try{ result = gi.Calculate(); if (result != null) { result.ForEach(x => sb.AppendLine(x.ToString())); } } catch (ImpossibleException e) { sb.Clear(); sb.Append("IMPOSSIBLE"); } Assert.AreEqual("IMPOSSIBLE", sb.ToString()); }
public void TestCase09() { var dir = System.Environment.CurrentDirectory; string testcase = "testcase9.txt"; string url = dir + "/../../" + testcase; GiftInvest gi = new GiftInvest(); gi.SetBudget(85614); if (System.IO.File.Exists(url)) { string[] lines = System.IO.File.ReadAllLines(url); foreach (string data in lines) { gi.AddOdds(int.Parse(data)); } } else { return; } StringBuilder sb = new StringBuilder(); List <int> result = null; try { result = gi.Calculate(); if (result != null) { result.ForEach(x => Console.WriteLine(x.ToString())); } } catch (ImpossibleException e) { sb.Clear(); sb.Append("IMPOSSIBLE"); } /* * StringBuilder ans = new StringBuilder(); * ans.AppendLine("1"); * ans.AppendLine("1"); * ans.AppendLine("1"); * * Assert.AreEqual(ans.ToString(), sb.ToString()); */ }