コード例 #1
0
        public void EqualPopAndPar()
        {
            Console.WriteLine("Equal population and parlament test started");
            var test = new JeffersonModel(4, 100, new List <int> {
                10, 15, 25, 50
            }, "OK");

            test.LoopToSuccess();
            var json = new JavaScriptSerializer().Serialize(test);

            Console.Write(json);
            Assert.AreEqual(0, test.PlacmentsList.Last().DividerCode);
        }
コード例 #2
0
        public void OnePlace()
        {
            Console.WriteLine("One place test started");
            var test = new JeffersonModel(4, 1, new List <int> {
                10, 15, 25, 50
            }, "OK");

            test.LoopToSuccess();
            var json = new JavaScriptSerializer().Serialize(test);

            Console.Write(json);
            Assert.AreEqual(0, test.PlacmentsList.Last().DividerCode);
        }
コード例 #3
0
        public void TestTendToInf()
        {
            var test = new JeffersonModel(3, 321, new List <int> {
                111, 222, 333
            }, "\nOK");

            try
            {
                test.LoopToSuccess();
            }
            catch (TendToInfinityException)
            {
                Assert.IsTrue(true);
            }
        }
コード例 #4
0
        public void SimpleData()
        {
            Console.WriteLine("Simple data test started");
            var test = new JeffersonModel(5, 105, new List <int> {
                105350, 128500, 153120, 98530, 117200
            }, "OK");

            test.LoopToSuccess();
            var json = new JavaScriptSerializer().Serialize(test);

            Console.Write(json);
            Assert.AreEqual(true, test.PlacmentsList.Last().SeatsPerStateList.SequenceEqual(new List <int> {
                18, 23, 27, 17, 20
            }));
        }
コード例 #5
0
        public void MaximumPlacement()
        {
            Console.WriteLine("Maximum values test started");
            var l = new List <int>();

            for (int i = 0; i < 10000; i++)
            {
                l.Add(200000);
            }
            var test = new JeffersonModel(10000, 100000, l, "\nOK");

            test.LoopToSuccess();
            var json = new JavaScriptSerializer().Serialize(test);

            Console.WriteLine("Test produce " + test.PlacmentsList.Count + " placement attemps.");
            Console.Write(json);
            Assert.AreEqual(0, test.PlacmentsList.Last().DividerCode);
        }
コード例 #6
0
        public void PresentUSA()
        {
            Console.WriteLine("Present USA test started");
            var test = new JeffersonModel(51, 435, new List <int>
            {//na podstawie http://pl.wikipedia.org/wiki/Stany_USA_wed%C5%82ug_liczby_ludno%C5%9Bci
                37253956,
                25145561,
                19378102,
                18801310,
                12830632,
                12702379,
                11536504,
                9883640,
                9687653,
                9535483,
                8791894,
                8001024,
                6724540,
                6547629,
                6483802,
                6392017,
                6346105,
                5988927,
                5773552,
                5686986,
                5303925,
                5029196,
                4779736,
                4625364,
                4533372,
                4339367,
                3831074,
                3751351,
                3574097,
                3046355,
                2967297,
                2915918,
                2853118,
                2763885,
                2700551,
                2059179,
                1852994,
                1826341,
                1567582,
                1360301,
                1328361,
                1316470,
                1052567,
                989415,
                900877,
                814180,
                710231,
                672591,
                625741,
                601723,
                563626
            }, "\nOK");
            Stopwatch sw = new Stopwatch();

            sw.Start();
            test.LoopToSuccess();
            var json = new JavaScriptSerializer().Serialize(test);

            sw.Stop();
            Console.WriteLine("Test took " + sw.Elapsed + " and produce " + test.PlacmentsList.Count + " placement attemps.");
            Console.Write(json);
            Assert.AreEqual(0, test.PlacmentsList.Last().DividerCode);
        }