public void TestMaxStepsCounterException() { int find = 149; int counter = 0; Container a = new Container('a', 1); Container b = new Container('b', 150); counter = ContainerSolver.NextStep(b, a, find, counter); }
public void ABitTougherSolution() { int find = 4; int counter = 0; Container a = new Container('a', 3); Container b = new Container('b', 5); counter = ContainerSolver.NextStep(a, b, find, counter); Assert.IsTrue(b.Units == find); Assert.IsTrue(counter == 6); Trace.TraceInformation("Solution Successful in {0} steps", counter); }
public void TestOneHundredVariationsWithExceptions() { Random rand = new Random(); List <Exception> exceptions = new List <Exception>(); for (int i = 0; i < 100; i++) { int min = 0; int max = 25; int find = rand.Next(min, max); int aC = rand.Next(min, max); int bC = rand.Next(min, max); int counter = 0; try { if (ContainerSolver.ValidateProblemVariables(find, aC, bC)) { Trace.TraceInformation("Starting: {0} : {1} / {2}", find, aC, bC); Container a = new Container('a', aC < bC ? aC : bC); Container b = new Container('b', aC < bC ? bC : aC); // Container "b" should be the largest if (find % a.Capacity == 0) { counter = ContainerSolver.NextStep(b, a, find, counter); } else { counter = ContainerSolver.NextStep(a, b, find, counter); } Assert.IsTrue(a.Units == find || b.Units == find); Trace.TraceInformation("Finished: {0} : {1} / {2} in {3} steps", find, aC, bC, counter); } } catch (Exception e) { exceptions.Add(e); } } Trace.TraceWarning("Execptions caught:{0}", exceptions.Count); exceptions.ForEach(x => Trace.TraceWarning(x.Message)); }
public void FindBucketSixModThree() { int find = 6; int counter = 0; Container a = new Container('a', 3); Container b = new Container('b', 9); if (find % a.Capacity == 0) { counter = ContainerSolver.NextStep(b, a, find, counter); } else { counter = ContainerSolver.NextStep(a, b, find, counter); } Assert.IsTrue(b.Units == find); Assert.IsTrue(counter == 4); Trace.TraceInformation("Solution Successful in {0} steps", counter); }
public void TestFindLargerThanBucketsValidation() { ContainerSolver.ValidateProblemVariables(10, 2, 4); }
public void TestEvenEvenOddValidation() { ContainerSolver.ValidateProblemVariables(3, 2, 4); }
public void TestZeroBucketCapacityException() { ContainerSolver.ValidateProblemVariables(4, 0, 5); }
public void TestZeroFindValueException() { ContainerSolver.ValidateProblemVariables(0, 3, 5); }
public void TestBucketsDivisibleEvenlyException() { Assert.IsTrue(ContainerSolver.ValidateProblemVariables(15, 3, 18)); ContainerSolver.ValidateProblemVariables(14, 3, 18); }