예제 #1
0
        public void TestUlamSpiralGetStartLocationOK()
        {
            UlamSpiral spiral = null;

            int[] location = null;


            spiral = new UlamSpiral(81);
            int[] centerLocation = spiral.GetCenterLocation();


            location = spiral.GetStartLocation(0);

            Assert.AreEqual(location[0], centerLocation[0]); // x
            Assert.AreEqual(location[1], centerLocation[1]); // y

            location = spiral.GetStartLocation(1);

            Assert.AreEqual(location[0], centerLocation[0] + 1); // x
            Assert.AreEqual(location[1], centerLocation[1]);     // y

            location = spiral.GetStartLocation(2);

            Assert.AreEqual(location[0], centerLocation[0] + 2); // x
            Assert.AreEqual(location[1], centerLocation[0] + 1); // y
        }
예제 #2
0
        public void TestUlamSpiralCycleOK()
        {
            UlamSpiral spiral = null;

            int[] loc         = null;
            int   cycleNumber = 0;

            spiral      = new UlamSpiral(25);
            cycleNumber = 1;
            spiral.Cycle(cycleNumber);
            loc = spiral.GetStartLocation(cycleNumber);
            Assert.AreEqual(2, spiral.Matrix[loc[1], loc[0]]);

            spiral      = new UlamSpiral(25);
            cycleNumber = 2;
            spiral.Cycle(cycleNumber);
            loc = spiral.GetStartLocation(cycleNumber);
            Assert.AreEqual(10, spiral.Matrix[loc[1], loc[0]]);

            spiral      = new UlamSpiral(49);
            cycleNumber = 3;
            spiral.Cycle(cycleNumber);
            loc = spiral.GetStartLocation(cycleNumber);
            Assert.AreEqual(26, spiral.Matrix[loc[1], loc[0]]);
        }