Esempio n. 1
0
        public void BCMoveTest()
        {
            string ret = "";

            SpacegameServer.BC.BusinessConnector bc;
            bc = new SpacegameServer.BC.BusinessConnector();

            Ship newShip = Mock.mockShip();

            newShip.systemid   = null;
            newShip.max_hyper  = 10;
            newShip.max_impuls = 10;
            newShip.hyper      = 10;
            newShip.impuls     = 10;

            var        OldPositionX = newShip.field.x;
            List <int> shipIds      = new List <int>();

            shipIds.Add(newShip.id);
            ret = bc.MoveFleet(shipIds, 6, newShip.userid, 1);

            SpacegameServer.BC.XMLGroups.MoveResultTree moveResult = null;
            System.Xml.Serialization.XmlSerializer      serializer = new System.Xml.Serialization.XmlSerializer(typeof(SpacegameServer.BC.XMLGroups.MoveResultTree));
            using (System.IO.TextReader reader = new System.IO.StringReader(ret))
            {
                moveResult = (SpacegameServer.BC.XMLGroups.MoveResultTree)serializer.Deserialize(reader);
            }

            Assert.AreEqual(1, moveResult.result);
            Assert.AreEqual(OldPositionX + 1, moveResult.ships.First(ship => ship.id == newShip.id).posX);
        }
Esempio n. 2
0
        public void BCMovePathTest()
        {
            string ret = "";

            SpacegameServer.BC.BusinessConnector bc;
            bc = new SpacegameServer.BC.BusinessConnector();

            Ship newShip = Mock.mockShip();

            newShip.systemid   = null;
            newShip.max_hyper  = 10;
            newShip.max_impuls = 10;
            newShip.hyper      = 10;
            newShip.impuls     = 10;

            var OldPositionX = newShip.field.x;

            List <int> shipIds = new List <int>();

            shipIds.Add(newShip.id);
            List <byte> directions = new List <byte>();

            directions.Add(6);
            directions.Add(6);
            ret = bc.MovePathFleet(shipIds, directions, newShip.userid, 1);

            //deserialize MovePathResult
            SpacegameServer.BC.XMLGroups.MovePathResult movePathResult = null;
            System.Xml.Serialization.XmlSerializer      serializer     = new System.Xml.Serialization.XmlSerializer(typeof(SpacegameServer.BC.XMLGroups.MovePathResult));
            using (System.IO.TextReader reader = new System.IO.StringReader(ret))
            {
                movePathResult = (SpacegameServer.BC.XMLGroups.MovePathResult)serializer.Deserialize(reader);
            }

            //deserialize the first string
            SpacegameServer.BC.XMLGroups.MoveResultTree moveResult = null;
            serializer = new System.Xml.Serialization.XmlSerializer(typeof(SpacegameServer.BC.XMLGroups.MoveResultTree));
            using (System.IO.TextReader reader = new System.IO.StringReader(movePathResult.StepResults[0]))
            {
                moveResult = (SpacegameServer.BC.XMLGroups.MoveResultTree)serializer.Deserialize(reader);
            }

            Assert.AreEqual(1, moveResult.result);
            Assert.AreEqual(OldPositionX + 1, moveResult.ships.First(ship => ship.id == newShip.id).posX, "Step 1 : wrong X coords");


            using (System.IO.TextReader reader = new System.IO.StringReader(movePathResult.StepResults[1]))
            {
                moveResult = (SpacegameServer.BC.XMLGroups.MoveResultTree)serializer.Deserialize(reader);
            }
            Assert.AreEqual(1, moveResult.result);
            Assert.AreEqual(OldPositionX + 2, moveResult.ships.First(ship => ship.id == newShip.id).posX, "Step 2 : wrong X coords");
        }