public async Task <IEnumerable <PolicyTemplate> > GetLatestAsync() { var policyFiles = GetAllPolicyFiles(); var policyTasks = policyFiles.Select(async filePath => { { var policyDocument = await ReadFileAsync(filePath); var policyName = Path.GetFileNameWithoutExtension(filePath); var policy = new PolicyTemplate( policyName, policyDocument ); return(policy); } }).ToArray(); var policies = await Task.WhenAll(policyTasks); return(policies); }
private bool IsThereAToastAction(string policyFile) { PolicyTemplate template = new PolicyTemplate(); template.Load(policyFile); List<IPolicy> policies = template.Policies; bool bToast = false; foreach (IPolicy policy in policies) { foreach (IPolicyChannel channel in policy.Channels) { if (channel.Type == ChannelType.ActiveContent) { SortedList<int, IAction> internalActions = template[policy.Name.Value, ChannelType.ActiveContent, Routing.Internal]; SortedList<int, IAction> externalActions = template[policy.Name.Value, ChannelType.ActiveContent, Routing.External]; if (internalActions.Count > 1) { IAction internalToastAction = ActiveContentPolicy.GetToastAction(internalActions); if (internalToastAction != null) return true; } if (externalActions.Count > 1) { IAction externalToastAction = ActiveContentPolicy.GetToastAction(externalActions); if (externalToastAction != null) return true; } } } } return bToast; }
public void Properties_Will_Be_Set() { // Arrange var name = "foo"; var document = "baaa"; var policyTemplate = new PolicyTemplate(name, document); // Act var policy = Policy.Create(policyTemplate); // Assert Assert.Equal(name, policy.Name); Assert.Equal(document, policy.Document); }
public void CapabilityName_Will_Be_Replaced_In_Document() { // Arrange var name = "foo"; var document = "foo capabilityName"; var policyTemplate = new PolicyTemplate(name, document); var capabilityName = new CapabilityName("baaa"); Func <PolicyTemplate, string> policyTemplateFormatter = (template) => { return(template.Document.Replace("capabilityName", capabilityName.ToString().ToLower())); }; // Act var policy = Policy.Create(policyTemplate, policyTemplateFormatter); // Assert var expectedDocument = "foo baaa"; Assert.Equal(expectedDocument, policy.Document); }
public CleanPolicyForTests(PolicyTemplate template, Dictionary<RiskRating, List<string>> riskRatings, bool forceBinaryCleanEnabled) : base(template, riskRatings) { m_forceBinaryCleanEnabled = forceBinaryCleanEnabled; }
public MockActiveContentPolicy(PolicyTemplate template) : base(template) { }