コード例 #1
0
ファイル: Test.cs プロジェクト: crudm/hs
        public void check()
        {
            play test = new play();

            test.field = new int[, ] {
                { 9, 9, 0, 0, 0 },
                { 9, 9, 9, 9, 0 },
                { 0, 9, 9, 9, 0 },
                { 0, 9, 9, 9, 0 }
            };

            Assert.AreEqual(false, test.check(0, 0));
            Assert.AreEqual(true, test.check(1, 0));
            Assert.AreEqual(false, test.check(2, 2));
        }
コード例 #2
0
ファイル: Test.cs プロジェクト: crudm/hs
        public void mines()
        {
            play test = new play();

            test.field = new int[5, 5];

            test.mines(10);

            int mines = 0;

            for (int i = 0; i < test.field.GetLength(0); i++)
            {
                for (int j = 0; j < test.field.GetLength(1); j++)
                {
                    if (test.field[i, j] == 9)
                    {
                        mines++;
                    }
                }
            }

            Assert.AreEqual(10, mines);

            bool isBroken = true;

            for (int i = 0; i < test.field.GetLength(0); i++)
            {
                for (int j = 0; j < test.field.GetLength(1); j++)
                {
                    if (test.check(i, j) == false)
                    {
                        isBroken = false;
                    }
                }
            }

            Assert.AreEqual(true, isBroken);
        }