public void TestPackFiles() { using var temp = new TempFolder(); var bspPath = $"{temp.FolderPath}/map.bsp"; File.Copy("testdata/map.bsp", bspPath); var filesToPack = new[] { "testdata/map.vmf" }; // Pack the files in the filesToPackList Program.PackFiles(new Options { BSPPath = bspPath, ContentPath = "testdata" }, filesToPack); // Load the BSP to make sure we can find the files var bsp = new BSP(bspPath); var pakLump = (PakfileLump)bsp.Lumps[(int)LumpType.Pakfile]; var archive = pakLump.OpenArchiveStream(ZipArchiveMode.Read); // Intersect the names of the paklump's entries with our set of files. The resulting list should be of equal length as our filesToPack if all of them exist in the lump. Assert.Equal(filesToPack.Length, archive.Entries .Select(entry => entry.FullName) .Intersect(filesToPack.Select(str => Program.ToRelativePath(str, "testdata"))).Count()); pakLump.CloseArchiveStream(); }
public void TestRelativePath() { Assert.Equal(@"Path.txt", Program.ToRelativePath(@"C:\Test\Path.txt", @"C:\Test")); Assert.Equal(@"Path.txt", Program.ToRelativePath(@"C:\Test\Path.txt", @"C:\Test\")); Assert.Equal(@"Path.txt", Program.ToRelativePath(@"C:/Test/Path.txt", @"C:/Test")); Assert.Equal(@"Path.txt", Program.ToRelativePath(@"C:/Test/Path.txt", @"C:/Test/")); Assert.Throws <ArgumentException>(() => { Program.ToRelativePath(@"C:\Test\Path.txt", @"C:\Hello"); }); }