示例#1
0
        public void StartTestCaseTest()
        {
            var exercise2 = new Models.Exercise2();
            exercise2.T = 50;
            exercise2.N = 2;

            Space space = new Space(500, 125, 500);

            List<TestCase> testCaseList = new List<TestCase>();
            Exercise2.PositionValue = Exercise2.GetValue(space.Height, space.Width, space.Depth);

            int nTemp = 0;
            for (var i = 1; i <= exercise2.T; i++)
            {
                List<Bomb> bombs = new List<Bomb>();
                nTemp = exercise2.N;

                for (var j = 1; j <= exercise2.N; j++)
                {
                    Position myPosition = new Position(200);
                    bombs.Add(new Bomb(j, 500, 125, 500, myPosition));
                }

                testCaseList.Add(new TestCase(i, bombs));

                exercise2.N = nTemp;
            }

            foreach (var testCase in testCaseList)
            {
                foreach (var bomb in testCase.bombList)
                {
                    exercise2.BombValue = Exercise2.GetValue(bomb.Height, bomb.Width, bomb.Depth);

                    // Find the nearest bomb with the longest distance
                    Exercise2.Compare(exercise2.BombValue, bomb.Position.Distance, bomb.Number);
                }
                Assert.AreEqual(2, Exercise2.BombNumber);
            }
        }
示例#2
0
        public void StartTestCase()
        {
            T = 50;

            Random rnd = new Random();
            //N = rnd.Next(1, 200); /* Too much time to load in internet browser*/
            N = rnd.Next(1, 20);

            Space space = new Space(rnd.Next(0, 1000), rnd.Next(0, 1000), rnd.Next(0, 1000));

            List<TestCase> testCaseList = new List<TestCase>();
            PositionValue = GetValue(space.Height, space.Width, space.Depth);

            int nTemp = 0;
            for (var i = 1; i <= T; i++)
            {
                List<Bomb> bombs = new List<Bomb>();
                nTemp = N;

                for (var j = 1; j <= N; j++)
                {
                    Position myPosition = new Position(rnd.Next(10, 100));
                    bombs.Add(new Bomb(j, rnd.Next(0, 1000), rnd.Next(0, 1000), rnd.Next(0, 1000), myPosition));
                }

                testCaseList.Add(new TestCase(i, bombs));

                N = nTemp;
            }

            StringBuilder sb = new StringBuilder();

            foreach (var testCase in testCaseList)
            {
                resultTemp = 3000;
                nearest = 0;
                sb.AppendFormat("<b>Test case number {0}</b><br />", testCase.ID);

                foreach (var bomb in testCase.bombList)
                {
                    BombValue = GetValue(bomb.Height, bomb.Width, bomb.Depth);

                    // Find the nearest bomb with the longest distance
                    Compare(BombValue, bomb.Position.Distance, bomb.Number);

                    sb.Append(bomb.Print());
                }
                sb.AppendFormat("<b>Nearest bomb number {0}</b><br /><br />", BombNumber);
            }

            PrintCase = sb;
        }