Пример #1
0
        public Maps(string mapName) //constructor
        {
            //var mapToLoad = "_mapName";
            //LoadMap(mapToLoad);

            var mapfile = new MapFileReader(/*mapName*/);

            mapfile.ReadMapFile(mapName);
            mapName          = mapfile.mapName;
            mapImageFilePath = mapfile.mapImageFilepath;

            initialPlayerBank = mapfile.initialPlayerBank;

            numberOfWaves          = mapfile.numberOfWaves;
            numberOfOffensiveUnits = mapfile.numberOfOffensiveUnits;
            offensiveUnitType      = mapfile.offensiveUnitType;
            timeDelaybetweenSpawns = mapfile.timeDelaybetweenSpawns;

            rawPath = mapfile.rawPath;
        }
Пример #2
0
        public void TestMapValues()
        {
            fakeMapFile.ReadMapFile("Map01");
            _uut.mapName = fakeMapFile.mapName;
            //_uut.mapImageFilePath = fakeMapFile.mapImageFilepath;
            _uut.initialPlayerBank      = fakeMapFile.initialPlayerBank;
            _uut.timeDelaybetweenSpawns = fakeMapFile.timeDelaybetweenSpawns;
            _uut.numberOfWaves          = fakeMapFile.numberOfWaves;
            _uut.numberOfOffensiveUnits = fakeMapFile.numberOfOffensiveUnits;
            _uut.offensiveUnitType      = fakeMapFile.offensiveUnitType;


            Assert.That(_uut.mapName, Is.EqualTo("FirstMap"));
            //Assert.That(_uut.mapImageFilepath, Is.EqualTo(mapImageFilePath));
            Assert.That(_uut.initialPlayerBank, Is.EqualTo(100));
            Assert.That(_uut.timeDelaybetweenSpawns, Is.EqualTo(2));
            Assert.That(_uut.numberOfWaves, Is.EqualTo(5));
            Assert.That(_uut.numberOfOffensiveUnits, Is.EqualTo(10));
            Assert.That(_uut.offensiveUnitType, Is.EqualTo("Goblin"));
        }
Пример #3
0
        public void ShouldLoadMapFile()
        {
            string _mapname = "map01";
            //var mapFileReader = new MapFileReader(_mapname);
            //var filename = @"MapFiles\Map01.txt";

            string realMapName = "FirstMap";
            string realImageFilePath = "\\MapFiles\\Map01.png";
            int realInitialPlayerBank = 100;
            string realRawPathstring =
                "left;left;left;left;left;left;down;down;down;left;left;left;left;left;up;up;up;up;up;up;left;left;left;left;left;left;left;left;left;down;down;down;right;right;right;right;right;right;down;down;down;left;left;left;left;left;left;left;left;left;left;up;up;up;up;up;left;left;left;left";
            var realPathStack = new Stack<String>(realRawPathstring.Split(';'));
            int realnumberOfWaves = 5;
            int realNumberOfOffensiveUnits = 10;
            int realTimeDelaybetweenSpawns = 2;
            string realOffensiveUnitType = "Goblin";

            _uut.ReadMapFile("Map01");
            //_uut.mapFilePath = @"C:\Program Files (x86)\Jenkins\workspace\Projekt_Gruppe7_Coverage\TowerDefence\TowerDefence\ClassLibrary1\MapFiles\"
            Debug.WriteLine(_uut.mapFilePath);
            var filename = _uut.mapFileName;

            Assert.IsTrue(File.Exists(_uut.mapFilePath + filename));

            //var test = TestContext.CurrentContext.TestDirectory;

            Assert.AreEqual(realMapName, _uut.mapName);
            Assert.AreEqual(realImageFilePath, _uut.mapImageFilepath);
            Assert.AreEqual(realPathStack, _uut.rawPath);
            Assert.AreEqual(realInitialPlayerBank, _uut.initialPlayerBank);
            Assert.AreEqual(realnumberOfWaves, _uut.numberOfWaves);
            Assert.AreEqual(realNumberOfOffensiveUnits, _uut.numberOfOffensiveUnits);
            Assert.AreEqual(realTimeDelaybetweenSpawns, _uut.timeDelaybetweenSpawns);
            Assert.AreEqual(realOffensiveUnitType, _uut.offensiveUnitType);

            //Assert.AreEqual()
        }