public void ReduceXap_CreateNewFile_Test() { var fileSystem = Substitute.For<IFileSystem>(); var console = new StringWriter(); CreateFakeInputXap(fileSystem, ZipArchiveMode.Read, "A", "B"). AddResourceAssemblyPart("en", "A"). AddResourceAssemblyPart("en-US", "A"). AddResourceAssemblyPart("en", "B"); CreateFakeSourceXap(fileSystem, "A", "C"); MemoryStream outputStream = new MemoryStream(); fileSystem.FileExists("Output.xap").Returns(true); fileSystem.OpenArchive("Output.xap", ZipArchiveMode.Create).Returns(new ZipArchive(outputStream, ZipArchiveMode.Create, true)); var options = new Options() { Input = "Input.xap", Sources = new[] { "Source.xap" }, Output = "Output.xap" }; var builder = new XapBuilder(); builder.AddAssemblyPart("A", 1000); var minifier = new XapMinifier(fileSystem, console); minifier.ReduceXap(options); var output = new ZipArchive(outputStream, ZipArchiveMode.Read, true); Assert.AreEqual(3, output.Entries.Count); Assert.IsNotNull(output.GetEntry("B.dll")); Assert.IsNotNull(output.GetEntry("en\\B.resources.dll")); }
public void ReduceXap_UpdateExistingFileWithDuplicateResources_Test() { var fileSystem = Substitute.For<IFileSystem>(); var console = new StringWriter(); var inputBuilder = CreateFakeInputXap(fileSystem, ZipArchiveMode.Update, "A", "B"). AddResourceAssemblyPart("en", "A"); CreateFakeSourceXap(fileSystem, "A", "C"). AddResourceAssemblyPart("en", "A"); var options = new Options() { Input = "Input.xap", Sources = new[] { "Source.xap" } }; var minifier = new XapMinifier(fileSystem, console); minifier.ReduceXap(options); var output = inputBuilder.GetArchive(); Assert.AreEqual(2, output.Entries.Count); Assert.IsNotNull(output.GetEntry("AppManifest.xaml")); Assert.IsNotNull(output.GetEntry("B.dll")); }
public void ReduceXap_UpdateExistingFileWithRecompress_RecompressionSuccessful() { var fileSystem = Substitute.For<IFileSystem>(); var consoleBuilder = new StringBuilder(); var consoleOutput = new StringWriter(consoleBuilder); var inputBuilder = CreateFakeInputXap(fileSystem, ZipArchiveMode.Update, CompressionLevel.NoCompression, "A", "B"); CreateFakeSourceXap(fileSystem, "A", "C"); fileSystem.FileSize("Input.xap").Returns(s => inputBuilder.GetSize()); var options = new Options() { Input = "Input.xap", Sources = new[] { "Source.xap" }, Recompress = true }; var builder = new XapBuilder(); builder.AddAssemblyPart("A", 1000); var minifier = new XapMinifier(fileSystem, consoleOutput); minifier.ReduceXap(options); string console = consoleBuilder.ToString(); var output = inputBuilder.GetArchive(); Assert.AreEqual(2, output.Entries.Count); Assert.IsNotNull(output.GetEntry("B.dll")); }
public void ReduceXap_UpdateExistingFileWithRecompress_RecompressionCanceled() { var fileSystem = Substitute.For<IFileSystem>(); var console = new StringWriter(); var inputBuilder = CreateFakeInputXap(fileSystem, ZipArchiveMode.Update, "A", "B"); CreateFakeSourceXap(fileSystem, "A", "C"); var options = new Options() { Input = "Input.xap", Sources = new[] { "Source.xap" }, Recompress = true }; var builder = new XapBuilder(); builder.AddAssemblyPart("A", 1000); var minifier = new XapMinifier(fileSystem, console); minifier.ReduceXap(options); var output = inputBuilder.GetArchive(); Assert.AreEqual(2, output.Entries.Count); Assert.IsNotNull(output.GetEntry("B.dll")); }