コード例 #1
0
ファイル: MoveTests.cs プロジェクト: kmaddebas/GoatsMVC
        public void TestSlideMovesMove()
        {
            State s = new State();
            Board b = s.Board;
            Assert.IsNotNull(b.GetSpace(1, 3));
            Assert.IsNotNull(s.Tiger);
            AbstractMove g = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat);
            g.ExecuteMove(s);

            AbstractMove ts = new SlideMove(b.GetSpace(4, 4), b.GetSpace(3, 3), s.Tiger);
            Assert.IsNotNull(ts.StartSpace);
            Assert.IsNotNull(ts.EndSpace);
            Assert.IsNotNull(ts.Player);

            ts.ExecuteMove(s);
            Assert.AreEqual(b.GetSpace(4, 4).GetSpaceState(), 'X');
            Assert.AreEqual(b.GetSpace(3, 3).GetSpaceState(), 'T');

            AbstractMove gs = new SlideMove(b.GetSpace(1, 3), b.GetSpace(1, 4), s.Goat);
            gs.ExecuteMove(s);
            Assert.AreEqual(b.GetSpace(1, 3).GetSpaceState(), 'X');
            Assert.AreEqual(b.GetSpace(1, 4).GetSpaceState(), 'G');

            Console.WriteLine("Tested placement 1,3, tiger slide 4,4 to 3,3 and goat slide 1,3 to 1,4 \r\n" + s.Board.GetBoardPic());
        }
コード例 #2
0
ファイル: MoveTests.cs プロジェクト: kmaddebas/GoatsMVC
        public void TestCloneMove()
        {
            State s = new State();
            Board b = s.Board;
            Assert.IsNotNull(b.GetSpace(1, 3));
            Assert.IsNotNull(s.Tiger);
            GoatPlacementMove g1 = new GoatPlacementMove(null, b.GetSpace(1, 3), s.Goat);
            GoatPlacementMove g2 = (GoatPlacementMove) g1.Clone();
            Assert.AreNotEqual(g1, g2);
            Assert.AreEqual(g1.EndSpace, g2.EndSpace);

            TigerCaptureMove t1 = new TigerCaptureMove(b.GetSpace(0, 4), b.GetSpace(2, 2), b.GetSpace(1, 3), s.Tiger);
            Assert.IsNotNull(t1.StartSpace);
            TigerCaptureMove t2 = (TigerCaptureMove) t1.Clone();
            Assert.AreNotEqual(t1, t2);
            Assert.AreEqual(t1.EndSpace, t2.EndSpace);

            SlideMove s1 = new SlideMove(b.GetSpace(4, 4), b.GetSpace(3, 3), s.Tiger);
            Assert.IsNotNull(s1.StartSpace);
            SlideMove s2 = (SlideMove) s1.Clone();
            Assert.AreNotEqual(s1, s2);
            Assert.AreEqual(s1.EndSpace, s2.EndSpace);
        }