Exemplo n.º 1
0
        public void TestIndividualFilesMultiple()
        {
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            GameFilePlayAdapter adapter = new GameFilePlayAdapter();
            List <string>       wads    = new List <string>();

            using (ZipArchive za = ZipFile.OpenRead(Path.Combine("GameFiles", GetTestFiles().First().FileName)))
                wads.AddRange(za.Entries.Where(x => Path.GetExtension(x.Name) == ".wad").Select(x => x.FullName));

            using (ZipArchive za = ZipFile.OpenRead(Path.Combine("GameFiles", GetTestFiles().Skip(1).First().FileName)))
                wads.AddRange(za.Entries.Where(x => Path.GetExtension(x.Name) == ".wad").Select(x => x.FullName));

            using (ZipArchive za = ZipFile.OpenRead(Path.Combine("GameFiles", GetTestFiles().Skip(2).First().FileName)))
                wads.AddRange(za.Entries.Where(x => Path.GetExtension(x.Name) == ".wad").Select(x => x.FullName));

            //this is test4.zip and it will NOT be added to the additional files list
            using (ZipArchive za = ZipFile.OpenRead(Path.Combine("GameFiles", GetTestFiles().Skip(3).First().FileName)))
                wads.AddRange(za.Entries.Where(x => Path.GetExtension(x.Name) == ".wad").Select(x => x.FullName));

            adapter.AdditionalFiles = GetTestFiles().Skip(1).Take(2).ToArray(); //test2.wad, test3.wad only
            adapter.SpecificFiles   = wads.ToArray();

            string parameters = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFiles().First(), GetTestPort(".wad,.deh"), false);

            Assert.IsNull(adapter.LastError);
            Assert.IsTrue(parameters.Contains("test1.wad"));
            Assert.IsTrue(parameters.Contains("test2.wad"));
            Assert.IsTrue(parameters.Contains("test3.wad"));
            Assert.IsFalse(parameters.Contains("test4.wad"));
            Assert.IsFalse(parameters.Contains(".deh"));
        }
Exemplo n.º 2
0
        public void TestWarp()
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 9; j++)
                {
                    string map = string.Format("E{0}M{1}", i + 1, j + 1);
                    Assert.AreEqual(GameFilePlayAdapter.BuildWarpParamter(map), string.Format(" -warp {0} {1}", i + 1, j + 1));
                }
            }

            for (int i = 0; i < 32; i++)
            {
                string map = null;
                if (i + 1 > 9)
                {
                    map = string.Format("MAP{0}", i + 1);
                }
                else
                {
                    map = string.Format("MAP0{0}", i + 1);
                }

                Assert.AreEqual(GameFilePlayAdapter.BuildWarpParamter(map), string.Format(" -warp {0}", i + 1));
            }

            Assert.AreEqual(" -warp 0", GameFilePlayAdapter.BuildWarpParamter("MAP00"));
        }
Exemplo n.º 3
0
        public void TestAdditionalFiles()
        {
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            GameFilePlayAdapter adapter = new GameFilePlayAdapter();

            adapter.AdditionalFiles = GetTestFiles().Skip(1).ToArray();

            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.pk3,.deh"), false);

            //-file parameters should be together, then -deh files should be together
            string check = string.Format(" -file \"{0}\\Temp\\test2.wad\" \"{0}\\Temp\\test2.pk3\" \"{0}\\Temp\\test3.wad\" \"{0}\\Temp\\test3.pk3\" \"{0}\\Temp\\test4.wad\" \"{0}\\Temp\\test4.pk3\" \"{0}\\Temp\\test1.wad\" \"{0}\\Temp\\test1.pk3\"  -deh \"{0}\\Temp\\test2.deh\" \"{0}\\Temp\\test3.deh\" \"{0}\\Temp\\test4.deh\" \"{0}\\Temp\\test1.deh\" ",
                                         Directory.GetCurrentDirectory());

            Assert.AreEqual(check.Trim(), launch.Trim());

            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test2.wad")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test3.wad")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test4.wad")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.wad")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test2.deh")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test3.deh")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test4.deh")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.deh")));
        }
Exemplo n.º 4
0
 public void TestMap()
 {
     Assert.AreEqual(" +map START", GameFilePlayAdapter.BuildWarpParamter("START"));
     Assert.AreEqual(" +map MAPSTART", GameFilePlayAdapter.BuildWarpParamter("MAPSTART"));
     Assert.AreEqual(" +map MAP01START", GameFilePlayAdapter.BuildWarpParamter("MAP01START"));
     Assert.AreEqual(" +map MAP1", GameFilePlayAdapter.BuildWarpParamter("MAP1"));
     Assert.AreEqual(" +map MAP001", GameFilePlayAdapter.BuildWarpParamter("MAP001"));
 }
Exemplo n.º 5
0
        public void TestExtractFalse()
        {
            GameFilePlayAdapter adapter = new GameFilePlayAdapter();

            adapter.ExtractFiles = false;
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");
            string       launch       = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);

            Assert.IsFalse(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.wad")));
            Assert.IsFalse(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.deh")));
        }
Exemplo n.º 6
0
        public void TestRecord()
        {
            LauncherPath        gameFilePath = new LauncherPath("GameFiles");
            LauncherPath        tempPath     = new LauncherPath("Temp");
            GameFilePlayAdapter adapter      = new GameFilePlayAdapter();

            adapter.ExtractFiles = false;
            adapter.Record       = true;
            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);

            Assert.IsNotNull(adapter.RecordedFileName);
            Assert.IsTrue(launch.Contains(string.Concat("-record \"", adapter.RecordedFileName, "\"")));
        }
Exemplo n.º 7
0
        public void TestBadFile()
        {
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            GameFilePlayAdapter adapter = new GameFilePlayAdapter();
            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, new DoomLauncher.DataSources.GameFile()
            {
                FileName = "bad.zip"
            }, GetTestPort(".wad,.deh"), false);

            Assert.IsNull(launch);
            Assert.IsNotNull(adapter.LastError);
            Assert.IsTrue(adapter.LastError.Contains("bad.zip"));
        }
Exemplo n.º 8
0
        public void TestExtraWithStats()
        {
            GameFilePlayAdapter adapter      = new GameFilePlayAdapter();
            LauncherPath        gameFilePath = new LauncherPath("GameFiles");
            LauncherPath        tempPath     = new LauncherPath("Temp");
            var boomPort = GetPrBoomTestPort(".wad,.deh");

            boomPort.ExtraParameters = "-boomextra";

            adapter.ExtraParameters = "-extratest";
            adapter.SaveStatistics  = true;

            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), boomPort, false);

            Assert.IsTrue(launch.Contains(" -extratest "));
            Assert.IsTrue(launch.Contains(" -boomextra "));
            Assert.IsTrue(launch.Contains(" -levelstat"));
        }
Exemplo n.º 9
0
        public void TestBadAdditionalFile()
        {
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            GameFilePlayAdapter adapter = new GameFilePlayAdapter();

            adapter.AdditionalFiles = new IGameFile[] { new GameFile()
                                                        {
                                                            FileName = "badadd.zip"
                                                        } };

            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);

            Assert.IsNull(launch);
            Assert.IsNotNull(adapter.LastError);
            Assert.IsTrue(adapter.LastError.Contains("badadd.zip"));
        }
Exemplo n.º 10
0
        public void TestSkill()
        {
            LauncherPath        gameFilePath = new LauncherPath("GameFiles");
            LauncherPath        tempPath     = new LauncherPath("Temp");
            GameFilePlayAdapter adapter      = new GameFilePlayAdapter();

            adapter.ExtractFiles = false;
            adapter.Skill        = "3";
            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);

            //only add skill with map
            Assert.IsFalse(launch.Contains("-skill 3"));

            adapter.Map = "MAP01";
            launch      = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);
            Assert.IsTrue(launch.Contains("-skill 3"));
            Assert.IsTrue(launch.Contains("-warp 1"));
        }
Exemplo n.º 11
0
        public void TestParametersSourcePortExtraParams()
        {
            GameFilePlayAdapter adapter = new GameFilePlayAdapter();

            CreateDirectoriesAndFiles();

            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            var port = GetTestPort(".wad,.deh");

            port.ExtraParameters = "-extra";

            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), port, false);
            string check  = string.Format("-file \"{0}\"  -deh \"{1}\"  -extra",
                                          Path.Combine(Directory.GetCurrentDirectory(), "Temp", "test1.wad"),
                                          Path.Combine(Directory.GetCurrentDirectory(), "Temp", "test1.deh"));

            Assert.AreEqual(check.Trim(), launch.Trim());
        }
Exemplo n.º 12
0
        public void TestIndividualFiles()
        {
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            GameFilePlayAdapter adapter = new GameFilePlayAdapter();

            string[] wads;

            using (ZipArchive za = ZipFile.OpenRead(Path.Combine("GameFiles", GetTestFiles().First().FileName)))
                wads = za.Entries.Where(x => Path.GetExtension(x.Name) == ".wad").Select(x => x.FullName).ToArray();

            adapter.SpecificFiles = wads.ToArray();

            string parameters = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFiles().First(), GetTestPort(".wad,.deh"), false);

            Assert.IsNull(adapter.LastError);
            Assert.IsTrue(parameters.Contains(".wad"));
            Assert.IsFalse(parameters.Contains(".deh"));
        }
Exemplo n.º 13
0
        public void TestPlayDemo()
        {
            LauncherPath        gameFilePath = new LauncherPath("GameFiles");
            LauncherPath        tempPath     = new LauncherPath("Temp");
            GameFilePlayAdapter adapter      = new GameFilePlayAdapter();
            string demofile = Path.Combine(tempPath.GetFullPath(), "testplay.lmp");

            adapter.ExtractFiles = false;
            adapter.PlayDemo     = true;
            adapter.PlayDemoFile = demofile;
            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);

            //the file doesn't exist
            Assert.IsNull(launch);
            Assert.IsNotNull(adapter.LastError);

            File.WriteAllText(demofile, "test");
            launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);
            Assert.IsTrue(launch.Contains(string.Concat("-playdemo \"", demofile, "\"")));
        }
Exemplo n.º 14
0
        public void TestIndividualPathedFiles()
        {
            LauncherPath gameFilePath = new LauncherPath("GameFiles");
            LauncherPath tempPath     = new LauncherPath("Temp");

            GameFilePlayAdapter adapter = new GameFilePlayAdapter();
            //testpathed.zip
            string file = Path.Combine("data", "test.wad");

            IGameFile gameFile = new GameFile()
            {
                FileName = "testpathed.zip"
            };

            adapter.SpecificFiles = new string[] { file };

            string parameters = adapter.GetLaunchParameters(gameFilePath, tempPath, gameFile, GetTestPort(".wad,.deh"), false);

            Assert.IsNull(adapter.LastError);
            Assert.IsTrue(parameters.Contains("test.wad"));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test.wad")));
        }
Exemplo n.º 15
0
        public void TestParameters()
        {
            GameFilePlayAdapter adapter      = new GameFilePlayAdapter();
            LauncherPath        gameFilePath = new LauncherPath("GameFiles");
            LauncherPath        tempPath     = new LauncherPath("Temp");

            //test .wad and deh
            string launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad,.deh"), false);
            string check  = string.Format("-file \"{0}\"  -deh \"{1}\"",
                                          Path.Combine(Directory.GetCurrentDirectory(), "Temp", "test1.wad"),
                                          Path.Combine(Directory.GetCurrentDirectory(), "Temp", "test1.deh"));

            Assert.AreEqual(check.Trim(), launch.Trim());

            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.wad")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.deh")));

            //.wad only
            launch = adapter.GetLaunchParameters(gameFilePath, tempPath, GetTestFile(), GetTestPort(".wad"), false);
            check  = string.Format("-file \"{0}\"",
                                   Path.Combine(Directory.GetCurrentDirectory(), "Temp", "test1.wad"));
            Assert.AreEqual(check.Trim(), launch.Trim());
        }