public void ExtractShouldThrowExceptionWhenDisposed() { BA2GeneralArchive archive = BA2Loader.Load <BA2GeneralArchive>(SharedData.GeneralOneFileArchive); archive.Dispose(); var dir = SharedData.CreateTempDirectory(); using (var stream = new MemoryStream()) { Assert.Throws <ObjectDisposedException>(() => archive.Extract(0, dir, false)); Assert.Throws <ObjectDisposedException>(() => archive.Extract("test.txt", dir, false)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractToStream(0, stream)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractAll("", false)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractAll("", false, CancellationToken.None, null)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractFiles(new int[] { 0 }, dir, false)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractFiles(new int[] { 0 }, dir, false, CancellationToken.None, null)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractFiles(new string[] { "test.txt" }, dir, false)); Assert.Throws <ObjectDisposedException>(() => archive.ExtractFiles(new string[] { "test.txt" }, dir, false, CancellationToken.None, null)); // These methods should not throw ObjectDisposedException Assert.DoesNotThrow(() => { var files = archive.FileList; archive.GetIndexFromFilename("test.txt"); archive.GetIndexFromFilename("ajkkfajsdlkfjlkasdf"); var total = archive.TotalFiles; var header = archive.Header; }); } }
public void ExtractAllFromTwoFileArchive() { BA2GeneralArchive archive = BA2Loader.Load <BA2GeneralArchive>(SharedData.GeneralTwoFilesArchive); string temp = SharedData.CreateTempDirectory(); archive.ExtractAll(temp, false); Assert.IsTrue(File.Exists(Path.Combine(temp, "test.txt"))); Assert.IsTrue(File.Exists(Path.Combine(temp, "wazzup.bin"))); archive.Dispose(); }