public void TestDocXRestriction() { Workshare.Policy.Condition.RestrictionAnalyzer analysis = new RestrictionAnalyzer(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\external.doc"); string filenameX = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\external.docx"); using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, "something")) { string[] fileTypes = { "WordDocument" }; Assert.IsTrue(analysis.RestrictionPropertyMatchInFileType(testFile, fileTypes, "Text", "WSRestrictionLevel", "2")); } using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filenameX, "something")) { string[] fileTypes = { "WordDocumentX" }; Assert.IsTrue(analysis.RestrictionPropertyMatchInFileType(testFile, fileTypes, "Text", "WSRestrictionLevel", "2")); } }
public void TestPropertyMatchInFileType() { Workshare.Policy.Condition.RestrictionAnalyzer analysis = new RestrictionAnalyzer(); //nominal case - correct file type, correct properties string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\TestRestrictionProperties.doc"); string description = "This is an awesomely cool test doc with super funny custom properties. I made them up all by myself"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] fileTypes = { "WordDocument", "ExcelSpreadsheet" }; Assert.IsTrue(analysis.RestrictionPropertyMatchInFileType(testFile, fileTypes, "Text", "WSRestrictionLevel", "1")); // Assert.IsTrue(analysis.RestrictionPropertyMatchInFileType(testFile, fileTypes, "Text", "WSRestrictionPassword", "")); } //incorrect file type using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] fileTypes = { "ExcelSpreadsheet" }; Assert.IsFalse(analysis.RestrictionPropertyMatchInFileType(testFile, fileTypes, "Text", "WSRestrictionLevel", "1")); // Assert.IsFalse(analysis.RestrictionPropertyMatchInFileType(testFile, fileTypes, "Text", "WSRestrictionPassword", "")); } }