public void IncludeByChannelClassificationsTestExcl() { HashSet <string> channelDefinitions = new HashSet <string>(); channelDefinitions.Add("0.1.2.3.4"); channelDefinitions.Add("0.1.2"); channelDefinitions.Add("0.1.3"); channelDefinitions.Add("0.1.1"); XmlSortableGenericList <InclusionExclusionRule> advertInclusionsExclusions = new XmlSortableGenericList <InclusionExclusionRule>(); advertInclusionsExclusions.Add(new InclusionExclusionRule(IncludeExclude.Exclude, "0.1")); advertInclusionsExclusions.Add(new InclusionExclusionRule(IncludeExclude.Exclude, "0.1.2")); advertInclusionsExclusions.Add(new InclusionExclusionRule(IncludeExclude.Exclude, "0.1.1")); advertInclusionsExclusions.Add(new InclusionExclusionRule(IncludeExclude.Exclude, "0.2.1")); bool expected = false; bool actual; actual = TreeSearch.IncludeByChannelClassifications(channelDefinitions, advertInclusionsExclusions); Assert.AreEqual(expected, actual); }
/// <summary> /// Instantiating a channel will create the underlying HashSet of Assets and the inclusion and exclusion rules /// </summary> public Channel() { _channelAssets = new HashSet <ChannelAsset>(); _inclusionExclusionList = new XmlSortableGenericList <InclusionExclusionRule>(); }
public AdvertAsset() { _inclusionExclusionList = new XmlSortableGenericList <InclusionExclusionRule>(); }
/// <summary> /// Checks if an advert is to be included in the playlist by checking the channel classifications against the advert's rules /// (adverts selecting which channels they 'want' to be featured in). /// </summary> /// <param name="advertInclusionsExclusions">The list that holds the inclusion and exclusion rules. It has already been sorted from least specific to most specific.</param> /// <param name="channelDefinitions">All the channel definitions of the channels to which the end user is subscribed</param> /// <returns>true means advert is included in the playlist</returns> public static bool IncludeByChannelClassifications(HashSet <string> channelDefinitions, XmlSortableGenericList <InclusionExclusionRule> advertInclusionsExclusions) { // initialize the 'decision lollipop' bool bIncluded = true; foreach (string definition in channelDefinitions) { bIncluded = true; foreach (InclusionExclusionRule inclusionExclusionRule in advertInclusionsExclusions) { if (definition.StartsWith(inclusionExclusionRule.Rule)) { bIncluded = inclusionExclusionRule.IncEx == IncludeExclude.Include; } } if (bIncluded) { return(true); } } return(false); }