private void TestProgressPhase1() { // No product name or total tick count yet. using (var rec = new Deployment.WindowsInstaller.Record(2)) { rec.SetInteger(1, 2); rec.SetInteger(2, 0); this.OnMessage(InstallMessage.Progress, rec); } }
private void TestProgressPhase2() { // With product name, estimated tick count, generating script. using (var rec = new Deployment.WindowsInstaller.Record(4)) { // CommonData: set CurrentProductName. rec.SetInteger(1, 1); rec.SetString(2, "INSTALL"); this.OnMessage(InstallMessage.CommonData, rec); // Progress: master rest. rec.SetInteger(1, 0); // Master reset. rec.SetInteger(2, 50); // Total; test that 50 is added. rec.SetInteger(3, 0); // Forward. rec.SetInteger(4, 1); // Generating script. this.OnMessage(InstallMessage.Progress, rec); // ActionStart: set CurrentAction. rec.FormatString = "Action: [1]: [2]"; rec.SetString(1, "Time"); rec.SetString(2, "Testing"); this.OnMessage(InstallMessage.ActionStart, rec); // Progress: report progress. rec.SetInteger(1, 2); rec.SetInteger(2, 50); this.OnMessage(InstallMessage.Progress, rec); // Progress: expand total. rec.SetInteger(1, 3); rec.SetInteger(2, 50); this.OnMessage(InstallMessage.Progress, rec); } }
public void DeserializePSInstallerException() { PSInstallerException ex; var formatter = new BinaryFormatter(); using (var ms = new MemoryStream()) { // Serialize the error record. using (var record = new Deployment.WindowsInstaller.Record(2)) { record.FormatString = "Installed [2]"; record.SetInteger(1, 1715); record.SetString(2, "TEST"); using (ex = new PSInstallerException(record)) { formatter.Serialize(ms, ex); } } // Reset the position. ms.Position = 0; // Deserialize the error record. using (ex = formatter.Deserialize(ms) as PSInstallerException) { Assert.IsNotNull(ex); var error = ex.ErrorRecord; Assert.IsNotNull(error); Assert.AreEqual("Installed TEST", ex.Message, true); Assert.AreEqual("TEST", error.TargetObject as string, true); } } }
private void TestError() { using (var error = new Deployment.WindowsInstaller.Record(2)) { error.SetInteger(1, 1301); error.SetString(2, "error"); this.OnMessage(InstallMessage.Error, error); } }
public void ValidateErrorRecordForFusion() { using (var record = new Deployment.WindowsInstaller.Record(6)) { record.SetInteger(1, 1935); record.SetString(2, "TestComponent"); record.SetInteger(3, unchecked ((int)0x80070005)); record.SetString(4, "ITestInterface"); record.SetString(5, "TestFunction"); record.SetString(6, "TestAssembly"); using (var ex = new PSInstallerException(record)) { var error = ex.ErrorRecord; Assert.IsNotNull(error); Assert.AreEqual("TestAssembly", error.TargetObject as string, true); var info = error.CategoryInfo; Assert.IsNotNull(info); Assert.AreEqual(ErrorCategory.InvalidData, info.Category); } } }
public void ValidateErrorRecordOpenError() { using (var record = new Deployment.WindowsInstaller.Record(2)) { record.SetInteger(1, 1301); record.SetString(2, @"C:\test.txt"); using (var ex = new PSInstallerException(record)) { var error = ex.ErrorRecord; Assert.IsNotNull(error); Assert.AreEqual(@"C:\test.txt", error.TargetObject as string, true); var info = error.CategoryInfo; Assert.IsNotNull(info); Assert.AreEqual(ErrorCategory.WriteError, info.Category); } } }
private void TestProgressPhase3() { // With product name, estimated tick count, executing script. using (var rec = new Deployment.WindowsInstaller.Record(4)) { // CommonData: set CurrentProductName. rec.SetInteger(1, 1); rec.SetString(2, "INSTALL"); this.OnMessage(InstallMessage.CommonData, rec); // Progress: master reset. rec.SetInteger(1, 0); // Master reset. rec.SetInteger(2, 100); // Total. rec.SetInteger(3, 0); // Forward. rec.SetInteger(4, 0); // Executing script. this.OnMessage(InstallMessage.Progress, rec); // ActionStart: set CurrentAction. rec.FormatString = "Action: [1]: [2]"; rec.SetString(1, "Time"); rec.SetString(2, "Testing"); rec.SetString(3, null); this.OnMessage(InstallMessage.ActionStart, rec); // Progress: update progress. rec.SetInteger(1, 1); // update progress. rec.SetInteger(2, 50); // Step. rec.SetInteger(3, 1); // Enable ActionData. this.OnMessage(InstallMessage.Progress, rec); // ActionData: set CurrentActionDetail and step progress. rec.FormatString = "Testing: [1]"; rec.SetString(1, "ActionData"); this.OnMessage(InstallMessage.ActionData, rec); } }
public void ValidateErrorRecordForFusion() { using (var record = new Deployment.WindowsInstaller.Record(6)) { record.SetInteger(1, 1935); record.SetString(2, "TestComponent"); record.SetInteger(3, unchecked((int)0x80070005)); record.SetString(4, "ITestInterface"); record.SetString(5, "TestFunction"); record.SetString(6, "TestAssembly"); using (var ex = new PSInstallerException(record)) { var error = ex.ErrorRecord; Assert.IsNotNull(error); Assert.AreEqual("TestAssembly", error.TargetObject as string, true); var info = error.CategoryInfo; Assert.IsNotNull(info); Assert.AreEqual(ErrorCategory.InvalidData, info.Category); } } }