示例#1
0
        public async Task BrtUs_UnpackReportsProgress()
        {
            using (var brtUS = new NdsRom())
            {
                // Arrange
                var progressReports = new ConcurrentBag <ProgressReportedEventArgs>();

                void onProgressed(object sender, ProgressReportedEventArgs e)
                {
                    progressReports.Add(e);
                }

                brtUS.ProgressChanged += onProgressed;

                await brtUS.OpenFile(BrtUsPath, SourceProvider);

                // Act
                await brtUS.Unpack(BrtUsUnpackDir, OutputProvider);

                // Assert
                // Make sure we have a reasonable distribution of percentages, and not all 0 or 1
                Assert.AreEqual(progressReports.Count, progressReports.Select(x => x.Progress).Count(), 0, "Too many duplicate progress percentages detected.");

                // Cleanup
                brtUS.ProgressChanged -= onProgressed;
            }

            // Cleanup
            OutputProvider.DeleteDirectory(BrtUsUnpackDir);
        }
示例#2
0
        static void Main(string[] args)
        {
            if (args.Length < 2)
            {
                PrintUsage();
                return;
            }

            var    filename     = args[0];
            var    dir          = args[1];
            string dataOverride = null;

            if (!Path.IsPathRooted(filename))
            {
                filename = Path.Combine(Directory.GetCurrentDirectory(), filename);
            }

            if (!Path.IsPathRooted(dir))
            {
                dir = Path.Combine(Directory.GetCurrentDirectory(), dir);
            }

            for (int i = 2; i < args.Length; i += 1)
            {
                switch (args[i])
                {
                case "--datapath":
                    if (i < args.Length - 1)
                    {
                        dataOverride = args[i + 1];
                    }
                    break;
                }
            }

            using (var file = new NdsRom())
            {
                if (!string.IsNullOrEmpty(dataOverride))
                {
                    file.DataPath = dataOverride;
                }

                file.OpenFile(filename, new PhysicalFileSystem()).Wait();

                if (File.Exists(filename))
                {
                    file.Unpack(dir, new PhysicalFileSystem()).Wait();
                }
                else if (Directory.Exists(filename))
                {
                    file.Save(dir, new PhysicalFileSystem()).Wait();
                }
            }
        }
示例#3
0
        public async Task TestPackEOS()
        {
            using (var eosUS = new NdsRom())
            {
                await eosUS.OpenFile(EosUsPath, SourceProvider);

                await eosUS.Unpack(EosUsUnpackDir, OutputProvider);

                await eosUS.Save("eos-repack.nds", OutputProvider);

                using (var eosRepack = new NdsRom())
                {
                    await eosRepack.OpenFile("eos-repack.nds", OutputProvider);

                    await eosUS.Unpack(EosUsUnpackDir + "-Reunpack", OutputProvider);
                }
            }

            // Cleanup
            OutputProvider.DeleteFile("eos-repack.nds");
            OutputProvider.DeleteDirectory(EosUsUnpackDir + "-Reunpack");
        }