public void TestDefaultValues() { LightSpeedCleanUserAction action = new LightSpeedCleanUserAction(); LightSpeedCleanUserActionInstaller actionInstaller = new LightSpeedCleanUserActionInstaller(); Assert.AreEqual(RunAt.Both, actionInstaller.ExecuteLocations[0], "Runs at both"); Assert.AreEqual("LightSpeed Clean", action.Name, "Default display name not set"); Assert.AreEqual(18, action.SupportedFileCollection.SupportedFiles().Length, "We support Word, Wordx, Wordm, Excel, Excelx, Excelm, PowerPoint, PowerPointx and PowerPointm"); Assert.IsTrue(action.SupportedFileCollection.Supports(".rtf"), "Binary Clean supports RTF documents"); Assert.IsTrue(action.SupportedFileCollection.Supports(".doc"), "Binary Clean supports Word documents"); Assert.IsTrue(action.SupportedFileCollection.Supports(".xls"), "Binary Clean supports Excel spreadsheets"); Assert.IsTrue(action.SupportedFileCollection.Supports(".ppt"), "Binary Clean supports PowerPoint presentations"); Assert.IsTrue(action.SupportedFileCollection.Supports(".docx"), "Binary Clean supports Wordx documents"); Assert.IsTrue(action.SupportedFileCollection.Supports(".docm"), "Binary Clean supports Wordm documents"); Assert.IsTrue(action.SupportedFileCollection.Supports(".xlsx"), "Binary Clean supports Excelx spreadsheets"); Assert.IsTrue(action.SupportedFileCollection.Supports(".xlsm"), "Binary Clean supports Excelm spreadsheets"); Assert.IsTrue(action.SupportedFileCollection.Supports(".pptx"), "Binary Clean supports PowerPointx presentations"); Assert.IsTrue(action.SupportedFileCollection.Supports(".pptm"), "Binary Clean supports PowerPointm presentations"); Assert.AreEqual(POLICTYPES.Length, actionInstaller.SupportedPolicyTypes.Count, "Incorrect number of supported policy types"); foreach (PolicyType expectedChannel in POLICTYPES) { Assert.IsTrue(actionInstaller.SupportedPolicyTypes.Contains(expectedChannel), String.Format("Expected policy type ({0}) not found", expectedChannel)); } }
public void TestFallbackCleaningDoesntHappenInServerCtxt() { using (WsActivationContext wsac = new WsActivationContext()) { ActionPropertySet aps = new ActionPropertySet(new CleanActionPropertySet()); aps.SystemProperties["RunAt"] = new ActionProperty("RunAt", "Server"); // setup server execution context aps.SystemProperties.Add( "FileType", new ActionProperty("FileType", typeof(string), PropertyDisplayType.Default, false, false, ".ppt", true) ); // file is a password protected ppt document string tempFile = CopyFile(TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\Projects\Hygiene\src\TestDocuments\both.ppt")); ActionDataImpl adi = new ActionDataImpl(tempFile); adi.Properties["DisplayName"] = Path.GetFileName(tempFile); adi.Properties["FileName"] = tempFile; LightSpeedCleanUserAction lsua = new LightSpeedCleanUserAction(); try { // file is a password protected ppt document lsua.Execute(adi, aps); } catch (Exception ex) { // exceptions are ignored here as we are expecting the clean to blow up actually Console.WriteLine(ex.ToString()); } Assert.IsNotNull(lsua.FallbackTried); Assert.IsFalse(lsua.FallbackTried.Value, "Expecting no fallback"); } }
public void RunningInServerCtxt() { LightSpeedCleanUserAction lscuac = new LightSpeedCleanUserAction(); ActionPropertySet template = lscuac.PropertySet; Assert.IsFalse(template.SystemProperties.ContainsKey("RunAt")); Assert.IsFalse(LightSpeedCleanUserAction.RunningInServerCtxt(template)); //now run in server context template.SystemProperties.Add("RunAt", new ActionProperty("RunAt", "Server")); Assert.IsTrue(LightSpeedCleanUserAction.RunningInServerCtxt(template), "Should be server context"); //now back to client template.SystemProperties["RunAt"].Value = "Client"; Assert.IsFalse(LightSpeedCleanUserAction.RunningInServerCtxt(template), "Should be client context"); // client even if gibberish template.SystemProperties["RunAt"].Value = "Foobar"; Assert.IsFalse(LightSpeedCleanUserAction.RunningInServerCtxt(template), "Should be client context"); }