public void TestPropertyMatchInFileType() { Workshare.Policy.Condition.CustomPropertyAnalyzer analysis = new CustomPropertyAnalyzer(); //nominal case - correct file type, correct properties string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\TestCustomProperties.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.PropertyMatchInFileType(testFile, fileTypes, "Text", "PinkPanther", "Watch me roar!")); Assert.IsTrue(analysis.PropertyMatchInFileType(testFile, fileTypes, "Text", "Glass", "Of water..")); Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Text", "Magically Appearing custom property", "")); Assert.IsTrue(analysis.PropertyMatchInFileType(testFile, fileTypes, "Number", "MyNumber", "456")); Assert.IsTrue(analysis.PropertyMatchInFileType(testFile, fileTypes, "Number", "MySecond Number", "225")); //Assert.IsTrue(analysis.PropertyMatchInFileType(testFile, fileTypes, "Date", "MyFileTile", "2006-12-25")); Assert.IsTrue(analysis.PropertyMatchInFileType(testFile, fileTypes, "YesNo", "Its a boolean", "True")); } //incorrect file type using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { string[] fileTypes = {"ExcelSpreadsheet"}; Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Text", "PinkPanther", "Watch me roar!")); Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Text", "Glass", "Of water..")); Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Text", "Magically Appearing custom property", "")); Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Number", "MyNumber", "456")); Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Number", "MySecond Number", "225")); //Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "Date", "MyFileTile", "2006-12-25")); Assert.IsFalse(analysis.PropertyMatchInFileType(testFile, fileTypes, "YesNo", "Its a boolean", "True")); } }
public void TestProperties() { Workshare.Policy.Condition.CustomPropertyAnalyzer analysis = new CustomPropertyAnalyzer(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\TestCustomProperties.doc"); string description = "This is an awesomely cool test doc with super funny custom properties. I made them up all by myself"; List<string> names = new List<string>(); names.Add("Glass"); names.Add("Flying Fluffy toys"); names.Add("Flying Fluffy toys!!!"); using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { Workshare.Policy.Condition.Property[] property = analysis.Properties(testFile, names.ToArray()); Assert.IsTrue(2 == property.Length, "Expected only 2 names to match"); Assert.AreEqual(property[0].Value, "Of water.."); Assert.AreEqual(property[1].Value, "Sometimes break stuff"); } }
public void TestPropertyMatchFindsWorkshareProperties() { Workshare.Policy.Condition.CustomPropertyAnalyzer analysis = new CustomPropertyAnalyzer(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\LotsOfWorkshareProperties.docx"); string description = "Loads of workshare properties"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, description)) { Assert.IsTrue(analysis.PropertyMatch(testFile, "Text", "WSClassification", "External Restriction")); Assert.IsTrue(analysis.PropertyMatch(testFile, "Text", "WS_RTS_TAG", "OCAAr8KIlRqpuK5zmBKDltT0JSn+vUnDK7YtHud6s264nSS8t01uD0zPPwDTZbiKUBzVrSRkQaEJZ57SjfKoX7QUoBYw9CiMsx+NqjG4+CpvWII/gdL8ek6ANogZenwSyiXrD5IbYRWjfe4=")); Assert.IsTrue(analysis.PropertyMatch(testFile, "Text", "EVOLVING_DOC_ID", "uBAAdjVIoQzWbbimc6WNY7Q6l40CRa5bTK0T2ZHgpLIOrCwII0HDgzbN/e3YS4e8roBc8nX2dnZZA6M7DrcAPhhv9z7+/03VwvPw3uzlHTis1kg=")); Assert.IsTrue(analysis.PropertyMatch(testFile, "Text", "SFR_COMPUTER_NAME", "sAAAjKXNsa8RXiRNoW+7FQ7QHPjz239QGVaIMY5n1WmmAUM=")); Assert.IsTrue(analysis.PropertyMatch(testFile, "Text", "WSRestrictionLevel", "1")); } }
public void TestUnicodeProperty() { Workshare.Policy.Condition.CustomPropertyAnalyzer analysis = new CustomPropertyAnalyzer(); string filename = Workshare.TestUtils.TestFileUtils.MakeRootPathAbsolute(@"\projects\Hygiene\src\ContentAnalysis.Tests\docs\UnicodeCustomProperty.doc"); string expectedPropertyNameAndValue = "五分之一"; using (IFile testFile = Workshare.Policy.Engine.FileFactory.Create(filename, "UnicodeCustomProperty")) { Workshare.Policy.Condition.Property[] property = analysis.Properties(testFile, new string[] { expectedPropertyNameAndValue }); Assert.IsTrue(1 == property.Length, "Expected only 1 name to match"); Assert.AreEqual(expectedPropertyNameAndValue, property[0].Value); } }