public MessageProcessor( int numEmails, int bodySize, int numAttachments, string attachmentFileName, string attachmentPath ) { if( !System.IO.Directory.Exists( attachmentPath ) ) throw new System.IO.DirectoryNotFoundException( "attachmentPath must be valid" ); this.bodySize = bodySize; this.numAttachments = numAttachments; // this.attachmentSize = attachmentSize; this.attachmentPath = attachmentPath; this.numEmails = numEmails; this.attachmentFileName = attachmentFileName; if (!string.IsNullOrEmpty(attachmentFileName)) { FileInfo fi = new FileInfo(attachmentPath + attachmentFileName); if (fi == null) throw new System.IO.FileNotFoundException("missing test file"); this.attachmentSize = fi.Length; } m_policyEngine = CreatePolicyEngine(); }
private Workshare.Policy.Engine.UroPolicyEngine BuildMockPolicyEngine(string sRulesFile) { if ((m_mockEngine != null) && (sRulesFile == m_lastRulesFile)) return m_mockEngine; Workshare.Policy.Engine.UroPolicyEngine engine = new Workshare.Policy.Engine.UroPolicyEngine(); string sObjectsFile = GetObjectsFileForRulesFile(sRulesFile); if (sObjectsFile == null) { throw new Exception("No objects file found - test cannot run"); } string rulesxml = System.IO.File.ReadAllText(sRulesFile); string objectsxml = System.IO.File.ReadAllText(sObjectsFile); IPolicyCache cache = new MockPolicyCache(); cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("", "").Content = rulesxml; cache.PolicySets[0].LatestVersion.GetCompiledPolicySet("", "").ObjectReferences = objectsxml; engine.PolicyCache = cache; m_mockEngine = engine; m_lastRulesFile = sRulesFile; return m_mockEngine; }
private Workshare.Policy.Engine.UroPolicyEngine CreatePolicyEngine() { Workshare.Policy.Engine.UroPolicyEngine policyEngine = new Workshare.Policy.Engine.UroPolicyEngine(); policyEngine.PolicyCache = new Workshare.Policy.ClientCache.LocalPolicyCache(this.attachmentPath, false); Workshare.Policy.Interfaces.UniversalRequestObject uro = UroHelpers.GetUroFromMailMessage(CreateMailMessage("*****@*****.**", "Test"), ""); policyEngine.ProcessPolicies( RunAt.Client, uro, Workshare.Policy.Interfaces.ProcessLevel.Actions ); return policyEngine; }
private Workshare.Policy.Engine.UroPolicyEngine BuildRealPolicyEnging() { if (m_realPolicyEngine == null) { m_realPolicyEngine = new Workshare.Policy.Engine.UroPolicyEngine(); m_realPolicyEngine.PolicyCache = Workshare.Policy.ClientCache.PolicyProxy.CreateLocalRuntimeCache(); } return m_realPolicyEngine; }