public void Test_02_TestForRegionalSettings() { System.Globalization.CultureInfo oldCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fi-FI"); System.Globalization.CultureInfo newCultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture; try { Assert.AreNotEqual(oldCultureInfo, newCultureInfo); Assert.AreEqual(newCultureInfo, System.Globalization.CultureInfo.GetCultureInfo("fi-FI")); Process[] pro = Process.GetProcessesByName("excel"); if (pro != null && pro.Length != 0) throw new System.InvalidOperationException("excel should not be running"); using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile()) { file.setTempDir("Temp.xls"); file.CreateFile(); // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(FileType.ExcelSheet); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ".xls", true)); props[CleanOption.Comments].Value = true; props[CleanOption.TrackChanges].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); string outputFile = action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForExcelToShutDown(30000); Assert.AreEqual(newCultureInfo, System.Globalization.CultureInfo.GetCultureInfo("fi-FI")); } } } catch { } finally { System.Threading.Thread.CurrentThread.CurrentCulture = oldCultureInfo; } }
private void TestLoadAndCleanPPTFile(string fileName, FileType fileType, string ext) { using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile(fileName)) { // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(fileType); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ext, true)); props[CleanOption.Comments].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); testData.Properties.Add("CorrectedDisplayName", file.Filepath); action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForPowerPointToShutDown(30000); } } }
public void Test_01_BasicRoundTripForActionObjectOnly() { Process[] pro = Process.GetProcessesByName("winword"); if (pro != null && pro.Length != 0) throw new System.InvalidOperationException("winword should not be running"); using (WsActivationContext wsac = new WsActivationContext()) { using (TempResourceFile file = new TempResourceFile("Doc.doc")) { int revisionCount = 0; int commentCount = 0; GetRevisionAndCommmentCounts(file.Filepath, ref revisionCount, ref commentCount); Assert.AreEqual(1, revisionCount, "There is one track change in the document."); Assert.AreEqual(1, commentCount, "There is one comment in the document."); // Force a create on the foreground thread Workshare.ApplicationControllers.OfficeApplicationCache.Instance.Create(FileType.WordDocument); CleanPropertiesDisplayTranslator displayTranslator = CleanPropertiesDisplayTranslator.Instance; CleanUserAction action = new CleanUserAction(); ActionPropertySet props = new ActionPropertySet(new CleanActionPropertySet()); props.SystemProperties.Add(displayTranslator.SysProp_FileType, new ActionProperty(displayTranslator.SysProp_FileType, typeof(string), PropertyDisplayType.Default, false, false, ".doc", true)); props[CleanOption.Comments].Value = true; props[CleanOption.TrackChanges].Value = true; ActionDataImpl testData = new ActionDataImpl(file.Filepath); testData.Properties.Add(displayTranslator.StrmProp_DisplayName, file.Filepath); testData.Properties.Add("CorrectedDisplayName", file.Filepath); string outFile = action.Execute(testData, props); Workshare.ApplicationControllers.OfficeApplicationCache.Instance.ShutDown(); WaitForWordToShutDown(30000); GetRevisionAndCommmentCounts(outFile, ref revisionCount, ref commentCount); Assert.AreEqual(0, revisionCount, "Track changes should have been removed."); Assert.AreEqual(0, commentCount, "Comments should have been removed."); } } }