public void TestIgnoreRestrictionsOnInternalEmailOff() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(applyInternalDocumentRestrictionsOptions); SortedList<int, IAction> internalActions = template[TemplatePolicy.DocumentRestrictions, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.DocumentRestrictions, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count, "Expected 1 internal action"); Assert.AreEqual(1, externalActions.Count, "Expected 1 external action"); DocumentRestrictionsPolicy drp = new DocumentRestrictionsPolicy(template, options); drp.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifedTemplate = new PolicyTemplate(); modifedTemplate.Load(myPolicy); internalActions = modifedTemplate[TemplatePolicy.DocumentRestrictions, ChannelType.SMTP, Routing.Internal]; externalActions = modifedTemplate[TemplatePolicy.DocumentRestrictions, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count, "Expected 1 internal actions"); Assert.AreEqual(1, externalActions.Count, "Expected 1 external actions"); template.Close(); modifedTemplate.Close(); System.IO.File.Delete(runtimePolicy); System.IO.File.Delete(myPolicy); }
public void TestNoInternal() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(pdfExternal); SortedList<int, IAction> internalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count); Assert.AreEqual(1, externalActions.Count); PdfPolicy pdfPolicy = new PdfPolicy(template, options); pdfPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifedTemplate = new PolicyTemplate(); modifedTemplate.Load(myPolicy); internalActions = modifedTemplate[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal]; externalActions = modifedTemplate[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(0, internalActions.Count); Assert.AreEqual(1, externalActions.Count); modifedTemplate.Close(); System.IO.File.Delete(runtimePolicy); System.IO.File.Delete(myPolicy); }
public void TestApply() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(optionsxml); SortedList<int, IAction> internalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(2, internalActions.Count, "Unexpected number of actions"); Assert.AreEqual(2, externalActions.Count, "Unexpected number of actions"); IAction externalCleanAction = externalActions.Values[1]; IDataElement deTrackChanges = externalCleanAction.DataElements[17]; IDataElement deComments = externalCleanAction.DataElements[18]; IDataItem diTrackChanges = deTrackChanges.Data as IDataItem; IDataItem diComments = deComments.Data as IDataItem; bool originalTrackChangesValue = (bool)diTrackChanges.Value; bool originalCommentsValue = (bool)diComments.Value; MetadataSecurityRatings msr = new MetadataSecurityRatings(); CleanPolicy cleanPolicy = new CleanPolicy(template, options, msr.Read(riskRatingsPath)); cleanPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifiedTemplate = new PolicyTemplate(); modifiedTemplate.Load(myPolicy); internalActions = modifiedTemplate[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.Internal]; externalActions = modifiedTemplate[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, externalActions.Count, "Unexpected number of actions"); externalCleanAction = externalActions.Values[0]; deTrackChanges = externalCleanAction.DataElements[17]; deComments = externalCleanAction.DataElements[18]; diTrackChanges = deTrackChanges.Data as IDataItem; diComments = deComments.Data as IDataItem; bool modifiedTrackChangesValue = (bool)diTrackChanges.Value; bool modifiedCommentsValue = (bool)diComments.Value; Assert.AreNotEqual(modifiedCommentsValue, originalCommentsValue); Assert.AreNotEqual(modifiedTrackChangesValue, originalTrackChangesValue); cleanPolicy = null; template.Close(); modifiedTemplate.Close(); System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); }
public void TestApplyConditions() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(optionsxml); ContentPolicyReader cpr = new ContentPolicyReader(); List<ContentRule> contentRules = cpr.Read(contentPolicy); AlertPolicy alertPolicy = new AlertPolicy(template, options, contentRules); alertPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); template.Close(); System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); }
public void TestNoInternalExternal() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(noPdf); SortedList<int, IAction> internalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count); Assert.AreEqual(1, externalActions.Count); PdfPolicy pdfPolicy = new PdfPolicy(template, options); pdfPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifedTemplate = new PolicyTemplate(); modifedTemplate.Load(myPolicy); try { IPolicy policy = modifedTemplate[TemplatePolicy.PdfPolicy]; Assert.IsTrue(false, "The policy should have been removed"); } catch (System.IndexOutOfRangeException) { } modifedTemplate.Close(); System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); }
public void TestAllowOverride() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(pdfInternalExternal); IAction internalAction = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal].Values[0]; IAction externalAction = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External].Values[0]; IPolicyObjectCollection<IDataElement> dataElements = internalAction.DataElements; int allowOverride = 0; int total = dataElements.Count; foreach (IDataElement dataElement in dataElements) { if (string.Compare(dataElement["allowoverride"].Value, "true", true) == 0) { allowOverride++; } } Option allowPdfOverride = options.Find(Sections.GeneralPolicy, "{b22927e1-afce-4081-8ebf-3187ee1bfc15}"); allowPdfOverride.Value = "0"; PdfPolicy pdfPolicy = new PdfPolicy(template, options); pdfPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifedTemplate = new PolicyTemplate(); modifedTemplate.Load(myPolicy); internalAction = modifedTemplate[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal].Values[0]; dataElements = internalAction.DataElements; int modifedAllowOverride = 0; int modifiedTotal = dataElements.Count; foreach (IDataElement dataElement in dataElements) { if (string.Compare(dataElement["allowoverride"].Value, "true", false) == 0) { modifedAllowOverride++; } } modifedTemplate.Close(); System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); Assert.AreEqual(total, modifiedTotal, "The number of DataElements are not the same"); Assert.AreEqual(0, modifedAllowOverride, "All the DataElement's allowoverride attributes should have been set to false"); }
private void ExportDefaultPolicy() { string tempPolicyfile = GetPolicyTemplateFromResources(); PolicyTemplate template = new PolicyTemplate(); template.Load(tempPolicyfile); MetadataSecurityRatings msr = new MetadataSecurityRatings(); Dictionary<RiskRating, List<string>> riskRatings = msr.Read(MetadataSecurityRatingsFile); Dictionary<RiskRating, List<string>> PDFriskRatings = msr.Read(PDFMetadataSecurityRatingsFile); if (!HandleFootnotesAsHiddenData()) { riskRatings = RemoveFootnoteItemFromLowRiskRatingCollection(riskRatings); } List<IPolicyAction> policyActions = new List<IPolicyAction>(); policyActions.Add(new PdfPolicy(template)); policyActions.Add(new CleanPolicy(template, riskRatings)); policyActions.Add(new PDFCleanPolicy(template, PDFriskRatings)); policyActions.Add(new ZipPolicy(template)); //policyActions.Add(new DocumentRestrictionsPolicy(template)); policyActions.Add(new DetectWorkshareStyles(template)); if (ReportOnContentPolicyViolations()) { ContentPolicyReader cpr = new ContentPolicyReader(); List<ContentRule> contentRules = cpr.Read(ContentPolicyFile); policyActions.Add(new AlertPolicy(template, contentRules)); } else { template.RemovePolicy(TemplatePolicy.AlertPolicy); } bool hideOptionsDlgForInternal = HideEmailOptionsDlg(true /*internal routing*/); bool hideOptionsDlgForExternal = HideEmailOptionsDlg(false /*external routing*/); foreach (IPolicyAction policyAction in policyActions) { if (hideOptionsDlgForInternal) { MakeAllActionsTransparent(policyAction.InternalActions, true); } if (hideOptionsDlgForExternal) { MakeAllActionsTransparent(policyAction.ExternalActions, false); } policyAction.Apply(); } template.Save(PolicyFile, RuntimePolicyFile); }
public void TestCleanConditions() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(optionsxml); MetadataSecurityRatings msr = new MetadataSecurityRatings(); Dictionary<RiskRating, List<string>> riskRatings = msr.Read(riskRatingsPath); List<IPolicyAction> policyActions = new List<IPolicyAction>(); policyActions.Add(new CleanPolicy(template, options, riskRatings)); foreach (IPolicyAction policyAction in policyActions) { policyAction.Apply(); } string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate pt = new PolicyTemplate(); pt.Load(myPolicy); IPolicy cleanPolicy = pt[TemplatePolicy.CleaningPolicy]; List<IPolicyObject> conditionGroups = pt.GetConditions(cleanPolicy); IConditionGroup conditionGroup = conditionGroups[0] as IConditionGroup; foreach (ICondition condition in conditionGroup.Conditions) { string name = condition.Name.Value; IDataSource ds = condition.DataLeft.Data as IDataSource; IDataMethod dm = ds.Method; IPolicyObjectCollection<IParameter> parameters = dm.Parameters; if (parameters.Count != 4) throw new System.IndexOutOfRangeException("Unexpected number of parameters for condition"); PolicyObjectCollection<IDataItem> items = parameters[3].Value.Data as PolicyObjectCollection<IDataItem>; foreach (IDataItem di in items) { string diItem = di.Value as string; if (string.Compare(diItem, "Footnote", false) == 0) { System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); return; } } } System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); Assert.Fail("Should have found Footnote in the condition parameter list"); }
public void TestApplyHiddenDataExclusions() { List<string> exclusions = new List<string>(); exclusions.Add("ExcludeCustomProperties"); exclusions.Add("ExcludeFieldCodesAuthorInformation"); exclusions.Add("ExcludeFieldCodesDocumentInformation"); exclusions.Add("ExcludeFieldCodesFormFields"); exclusions.Add("ExcludeFieldCodesIncludeFields"); exclusions.Add("ExcludeFieldCodesIndexTables"); exclusions.Add("ExcludeFieldCodesNumbering"); exclusions.Add("ExcludeFieldCodesHyperlinks"); exclusions.Add("ExcludeFieldCodesLinks"); exclusions.Add("ExcludeFieldCodesReferences"); exclusions.Add("ExcludeFieldCodesEquationsFormulas"); exclusions.Add("ExcludeFieldCodesDocumentAutomation"); exclusions.Add("ExcludeDocumentVariables"); exclusions.Add("ExcludeFieldCodes"); exclusions.Add("DeleteFieldCodes"); PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(noFieldExclusions); SortedList<int, IAction> externalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; IAction externalClean = externalActions.Values[0]; IDataItem diExecute = externalClean.DataElements[1].Data as IDataItem; bool originalExecute = (bool)diExecute.Value; Assert.IsTrue(originalExecute); MetadataSecurityRatings msr = new MetadataSecurityRatings(); CleanPolicy cleanPolicy = new CleanPolicy(template, options, msr.Read(riskRatingsPath)); cleanPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifiedTemplate = new PolicyTemplate(); modifiedTemplate.Load(myPolicy); externalActions = modifiedTemplate[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; IAction externalAction = externalActions.Values[0]; bool exclusionsFound = false; bool foundFieldCodesIndexAndTables = false; for(int i = 0; i < externalAction.DataElements.Count; i++) { IDataItem di = externalAction.DataElements[i].Data as IDataItem; string name = di.Name.Value; if (string.IsNullOrEmpty(name)) continue; foreach(string s in exclusions) { if (string.Compare(s, name, true) == 0) { exclusionsFound = true; string value = di.Value.ToString(); if (string.Compare(name, "ExcludeFieldCodesIndexTables", true) == 0) { foundFieldCodesIndexAndTables = true; Assert.IsTrue(string.Compare(value, "true", true) == 0, name + " - Metadata exclusions should be set true"); break; } else if ((string.Compare(name, "ExcludeCustomProperties", true) == 0)) { Assert.IsTrue(string.Compare(value, "Custom One", true) == 0, name + " - Metadata exclusions should be set to empty string"); } else if ((string.Compare(name, "ExcludeDocumentVariables", true) == 0) || (string.Compare(name, "ExcludeFieldCodes", true) == 0) || (string.Compare(name, "DeleteFieldCodes", true) == 0)) { Assert.IsTrue(value.Length == 0, name + " - Metadata exclusions should be set to empty string"); } else { Assert.IsTrue(string.Compare(value, "false", true) == 0, name + " - Metadata exclusions should NOT be set to true"); break; } } } } Assert.IsTrue(exclusionsFound, "We didn't find any exclusions on the action - that is wrong"); Assert.IsTrue(foundFieldCodesIndexAndTables, "We didn't find ExcludeFieldCodesIndexTables on the action - that is wrong"); System.IO.File.Delete(runtimePolicy); System.IO.File.Delete(myPolicy); }
public void TestApplyAllowOptionOverride_False() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(noOverrideAllowed); MetadataSecurityRatings msr = new MetadataSecurityRatings(); CleanPolicy cleanPolicy = new CleanPolicy(template, options, msr.Read(riskRatingsPath)); cleanPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifiedTemplate = new PolicyTemplate(); modifiedTemplate.Load(myPolicy); SortedList<int, IAction> internalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count, "Unexpected number of actions"); Assert.AreEqual(1, externalActions.Count, "Unexpected number of actions"); IAction internalCleanAction = internalActions.Values[0]; IAction externalCleanAction = externalActions.Values[0]; for (int i = 0; i < internalCleanAction.DataElements.Count; i++) { IDataElement de = internalCleanAction.DataElements[i]; if (string.Compare(de.DisplayName.Value, "Apply to All", true) == 0 || string.Compare(de.DisplayName.Value, "Allow Override", true) == 0) { Assert.IsTrue(de["allowoverride"].Value == "True"); } else Assert.IsTrue(de["allowoverride"].Value == "False"); } for (int i = 0; i < externalCleanAction.DataElements.Count; i++) { IDataElement de = externalCleanAction.DataElements[i]; if (string.Compare(de.DisplayName.Value, "Apply to All", true) == 0 || string.Compare(de.DisplayName.Value, "Allow Override", true) == 0) { Assert.IsTrue(de["allowoverride"].Value == "True"); } else Assert.IsTrue(de["allowoverride"].Value == "False"); } modifiedTemplate.Close(); System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); }
public void TestApplySkipCleaningExternal() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(skipAllCleaningxml); SortedList<int, IAction> externalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; IAction externalClean = externalActions.Values[0]; IDataItem diExecute = externalClean.DataElements[1].Data as IDataItem; bool originalExecute = (bool)diExecute.Value; Assert.IsTrue(originalExecute); MetadataSecurityRatings msr = new MetadataSecurityRatings(); CleanPolicy cleanPolicy = new CleanPolicy(template, options,msr.Read(riskRatingsPath)); cleanPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifiedTemplate = new PolicyTemplate(); modifiedTemplate.Load(myPolicy); externalActions = modifiedTemplate[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; IAction externalAction = externalActions.Values[0]; IDataItem diModifiedExecute = externalAction.DataElements[1].Data as IDataItem; Assert.IsTrue((System.Convert.ToString(diExecute.Value) == "True")); Assert.IsTrue((System.Convert.ToString(diModifiedExecute.Value) == "True")); // True by default. System.IO.File.Delete(runtimePolicy); System.IO.File.Delete(myPolicy); }
public void TestApply_InkAnnotations() { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); Options options = new Options(options3xml); SortedList<int, IAction> internalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(2, internalActions.Count, "Unexpected number of actions"); Assert.AreEqual(2, externalActions.Count, "Unexpected number of actions"); IAction internalCleanAction = internalActions.Values[0]; IAction externalCleanAction = externalActions.Values[0]; IDataElement deIntInkAnnotations = internalCleanAction.DataElements[22]; IDataElement deExtInkAnnotations = externalCleanAction.DataElements[22]; IDataItem intInkAnnotations = deIntInkAnnotations.Data as IDataItem; IDataItem extInkAnnotations = deExtInkAnnotations.Data as IDataItem; bool originalInternalValue = (bool)intInkAnnotations.Value; bool originalExternalValue = (bool)extInkAnnotations.Value; MetadataSecurityRatings msr = new MetadataSecurityRatings(); CleanPolicyForTests cleanPolicy = new CleanPolicyForTests(template, options, msr.Read(riskRatingsPath), true); cleanPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate modifiedTemplate = new PolicyTemplate(); modifiedTemplate.Load(myPolicy); internalActions = modifiedTemplate[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.Internal]; externalActions = modifiedTemplate[TemplatePolicy.CleaningPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count, "Unexpected number of actions"); Assert.AreEqual(1, externalActions.Count, "Unexpected number of actions"); internalCleanAction = internalActions.Values[0]; externalCleanAction = externalActions.Values[0]; deIntInkAnnotations = internalCleanAction.DataElements[22]; deExtInkAnnotations = externalCleanAction.DataElements[22]; intInkAnnotations = deIntInkAnnotations.Data as IDataItem; extInkAnnotations = deExtInkAnnotations.Data as IDataItem; bool modifiedInternalValue = (bool)intInkAnnotations.Value; bool modifiedExternalValue = (bool)extInkAnnotations.Value; Assert.AreEqual(originalInternalValue, modifiedInternalValue, "The value should be the same"); Assert.AreNotEqual(originalExternalValue, modifiedExternalValue, "The value should not be the same"); template.Close(); modifiedTemplate.Close(); System.IO.File.Delete(myPolicy); System.IO.File.Delete(runtimePolicy); }
public void TestSaveRemoveActionPersistsToTemplate() { PolicyTemplate template = new PolicyTemplate(); template.Load(policy_file); SortedList<int, IAction> internalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal]; SortedList<int, IAction> externalActions = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(1, internalActions.Count); Assert.AreEqual(1, externalActions.Count); IPolicyChannel pdfSmtpChannel = template[TemplatePolicy.PdfPolicy, ChannelType.SMTP]; template.RemoveAction(pdfSmtpChannel, Routing.Internal, internalActions.Values[0]); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); PolicyTemplate updatedPolicy = new PolicyTemplate(); updatedPolicy.Load(myPolicy); internalActions = updatedPolicy[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.Internal]; externalActions = updatedPolicy[TemplatePolicy.PdfPolicy, ChannelType.SMTP, Routing.External]; Assert.AreEqual(0, internalActions.Count); Assert.AreEqual(1, externalActions.Count); }
public void TestSave() { PolicyTemplate template = new PolicyTemplate(); template.Load(policy_file); Options options = new Options(optionsxml); ZipPolicy zipPolicy = new ZipPolicy(template, options); zipPolicy.Apply(); string runtimePolicy = System.IO.Path.GetTempFileName(); string myPolicy = System.IO.Path.GetTempFileName(); template.Save(myPolicy, runtimePolicy); Assert.IsTrue(System.IO.File.Exists(runtimePolicy)); System.IO.FileInfo fi = new System.IO.FileInfo(runtimePolicy); Assert.IsTrue(fi.Length > 0); System.IO.File.Delete(runtimePolicy); System.IO.File.Delete(myPolicy); }