示例#1
0
        public void GetHashCode_DefaultValue_AreEqual()
        {
            var state = new MapState(1);

            var act = state.GetHashCode();
            var exp = 0;

            Assert.AreEqual(exp, act);
        }
示例#2
0
        public void GetHashCode_Transforms_AreEqual()
        {
            var exp = 16778040;

            var state0 = new MapState(2);

            state0.Set(1, 2, 13);
            state0.Set(2, 1, 53);
            state0.NextStep(2);
            state0.NextStep(2);

            var act0 = state0.GetHashCode();

            Assert.AreEqual(exp, act0, "hash act0");

            var state1 = new MapState(2);

            state1.Set(1, 2, 13);
            state1.Set(2, 1, 53);
            state1.NextStep(2);
            state1.Set(2, 0, 2);
            state1.Set(2, 2, 2);
            state1.Apply(Move.CreateStack(PlayerType.player2, 2, 13), this.TestMap);
            state1.Set(2, 1, 53);
            state1.Set(1, 2, 10);
            state1.Apply(Move.CreateStack(PlayerType.player1, 1, 3), this.TestMap);
            state1.NextStep(2);

            var act1 = state1.GetHashCode();

#if DEBUG
            DebugRegions debug0 = state0.ToDebug();
            DebugRegions debug1 = state1.ToDebug();
#endif
            Assert.AreEqual(state0.Owner(1), state1.Owner(1), "Owner[1]");
            Assert.AreEqual(state0.Armies(1), state1.Armies(1), "Armies[1]");

            Assert.AreEqual(state0.Owner(2), state1.Owner(2), "Owner[2]");
            Assert.AreEqual(state0.Armies(2), state1.Armies(2), "Armies[2]");

            //Assert.AreEqual(state0.PlayerToMove, state1.PlayerToMove, "PlayerToMove");
            Assert.AreEqual(state0.SubRound, state1.SubRound, "SubRound");


            Assert.AreEqual(exp, act1, "hash act1");
        }