コード例 #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"));
        }
コード例 #2
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")));
        }
コード例 #3
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"));
        }
コード例 #4
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, "\"")));
        }
コード例 #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")));
        }
コード例 #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, "\"")));
        }
コード例 #7
0
        public void TestParameters()
        {
            GameFilePlayAdapter adapter = new GameFilePlayAdapter();

            CreateDirectoriesAndFiles();

            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());

            //.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());
        }
コード例 #8
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"));
        }
コード例 #9
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"));
        }
コード例 #10
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"));
        }
コード例 #11
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"));
        }
コード例 #12
0
        public void TestParametersSourcePortExtraParams()
        {
            GameFilePlayAdapter adapter      = new GameFilePlayAdapter();
            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());

            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.wad")));
            Assert.IsTrue(File.Exists(Path.Combine(tempPath.GetFullPath(), "test1.deh")));
        }
コード例 #13
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")));
        }