Example #1
0
        private static void Verify <T>(Dictionary <T, double> expected, Dictionary <T, double> results, IApportionment <T> Test)
        {
            foreach (KeyValuePair <T, double> kv in results)
            {
                if (expected.ContainsKey(kv.Key) == false || Math.Abs(expected[kv.Key] - kv.Value) > .0001)
                {
                    Assert.Fail();
                }
            }

            //These numbers cannot be zero.
            //If they are zero then that means the code hasn't
            //changed it from its default value, meaning
            //that we are breaking out interface contract!
            if (Test.Allocation == 0)
            {
                Assert.Fail();
            }
            if (Test.StandardDivisor == 0)
            {
                Assert.Fail();
            }

            //Null Tests
            if (Test.Input == null)
            {
                Assert.Fail();
            }
            if (Test.Output == null)
            {
                Assert.Fail();
            }
            if (Test.STDQuota == null)
            {
                Assert.Fail();
            }
        }
Example #2
0
        static void Run <T>(IApportionment <T> test, Dictionary <T, double> expected)
        {
            var results = test.Run();

            Verify(expected, results, test);
        }