public void AddEmptyImage_Template(CompressionType compType, string wimFileName, AddFlags addFlags = AddFlags.DEFAULT) { string destDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); try { Directory.CreateDirectory(destDir); bool[] _checked = new bool[2]; for (int i = 0; i < _checked.Length; i++) { _checked[i] = false; } CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.WRITE_METADATA_BEGIN: Assert.IsNull(info); _checked[0] = true; break; case ProgressMsg.WRITE_METADATA_END: Assert.IsNull(info); _checked[1] = true; break; } return(CallbackStatus.CONTINUE); } // Capture Wim string wimFile = Path.Combine(destDir, wimFileName); using (Wim wim = Wim.CreateNewWim(compType)) { wim.RegisterCallback(ProgressCallback); wim.AddEmptyImage("UnitTest"); wim.Write(wimFile, Wim.AllImages, WriteFlags.DEFAULT, Wim.DefaultThreads); WimInfo wi = wim.GetWimInfo(); Assert.IsTrue(wi.ImageCount == 1); } for (int i = 0; i < _checked.Length; i++) { Assert.IsTrue(_checked[i]); } } finally { if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } } }
public void AddEmptyImageTemplate(CompressionType compType, string wimFileName) { string destDir = TestHelper.GetTempDir(); try { bool[] _checked = new bool[2]; for (int i = 0; i < _checked.Length; i++) { _checked[i] = false; } CallbackStatus ProgressCallback(ProgressMsg msg, object info, object progctx) { switch (msg) { case ProgressMsg.WriteMetadataBegin: Assert.IsNull(info); _checked[0] = true; break; case ProgressMsg.WriteMetadataEnd: Assert.IsNull(info); _checked[1] = true; break; } return(CallbackStatus.Continue); } // Capture Wim string wimFile = Path.Combine(destDir, wimFileName); using (Wim wim = Wim.CreateNewWim(compType)) { wim.RegisterCallback(ProgressCallback); wim.AddEmptyImage("UnitTest"); wim.Write(wimFile, Wim.AllImages, WriteFlags.None, Wim.DefaultThreads); WimInfo wi = wim.GetWimInfo(); Assert.IsTrue(wi.ImageCount == 1); } for (int i = 0; i < _checked.Length; i++) { Assert.IsTrue(_checked[i]); } } finally { if (Directory.Exists(destDir)) { Directory.Delete(destDir, true); } } }