public CallbackStatus UpdateProgress_Callback(ProgressMsg msg, object info, object progctx)
        {
            CallbackTested tested = progctx as CallbackTested;

            Assert.IsNotNull(tested);

            switch (msg)
            {
            case ProgressMsg.UPDATE_BEGIN_COMMAND:
            case ProgressMsg.UPDATE_END_COMMAND:
            {
                ProgressInfo_Update m = (ProgressInfo_Update)info;
                Assert.IsNotNull(m);

                tested.Set();

                UpdateCommand cmd = m.Command;
                switch (cmd.Op)
                {
                case UpdateOp.ADD:
                {
                    UpdateCommand.UpdateAdd add = cmd.Add;
                    Console.WriteLine($"ADD [{add.FsSourcePath}] -> [{add.WimTargetPath}]");
                }
                break;

                case UpdateOp.DELETE:
                {
                    UpdateCommand.UpdateDelete del = cmd.Delete;
                    Console.WriteLine($"DELETE [{del.WimPath}]");
                }
                break;

                case UpdateOp.RENAME:
                {
                    UpdateCommand.UpdateRename ren = cmd.Rename;
                    Console.WriteLine($"RENAME [{ren.WimSourcePath}] -> [{ren.WimTargetPath}]");
                }
                break;
                }
            }
            break;
            }

            return(CallbackStatus.CONTINUE);
        }
        public void Update_Template(string fileName, UpdateCommand[] cmds)
        {
            string destDir = TestHelper.GetTempDir();

            try
            {
                CallbackTested tested = new CallbackTested(false);
                Directory.CreateDirectory(destDir);

                string srcWimFile  = Path.Combine(TestSetup.SampleDir, fileName);
                string destWimFile = Path.Combine(destDir, fileName);
                File.Copy(srcWimFile, destWimFile, true);

                using (Wim wim = Wim.OpenWim(destWimFile, OpenFlags.WRITE_ACCESS, UpdateProgress_Callback, tested))
                {
                    wim.UpdateImage(1, cmds, UpdateFlags.SEND_PROGRESS);

                    wim.Overwrite(WriteFlags.DEFAULT, Wim.DefaultThreads);
                }

                List <string> entries = new List <string>();
                CallbackStatus IterateCallback(DirEntry dentry, object userData)
                {
                    entries.Add(dentry.FullPath);
                    return(CallbackStatus.CONTINUE);
                }

                using (Wim wim = Wim.OpenWim(destWimFile, OpenFlags.DEFAULT))
                {
                    wim.IterateDirTree(1, Wim.RootPath, IterateFlags.RECURSIVE, IterateCallback, entries);
                }

                Assert.IsTrue(tested.Value);
                foreach (UpdateCommand cmd in cmds)
                {
                    switch (cmd.Op)
                    {
                    case UpdateOp.ADD:
                    {
                        UpdateCommand.UpdateAdd add = cmd.Add;
                        Assert.IsTrue(entries.Contains(Path.Combine(Wim.RootPath, add.WimTargetPath), StringComparer.Ordinal));
                    }
                    break;

                    case UpdateOp.DELETE:
                    {
                        UpdateCommand.UpdateDelete del = cmd.Delete;
                        Assert.IsFalse(entries.Contains(Path.Combine(Wim.RootPath, del.WimPath), StringComparer.Ordinal));
                    }
                    break;

                    case UpdateOp.RENAME:
                    {
                        UpdateCommand.UpdateRename ren = cmd.Rename;
                        Assert.IsTrue(entries.Contains(Path.Combine(Wim.RootPath, ren.WimTargetPath), StringComparer.Ordinal));
                    }
                    break;
                    }
                }
            }
            finally
            {
                if (Directory.Exists(destDir))
                {
                    Directory.Delete(destDir, true);
                }
            }
        }