Example #1
0
        /// <summary>
        /// Creates a HashSet of assets to be included in the user's playlist.
        /// Uses the Channel's ChannelAsset HashSet.
        /// </summary>
        /// <returns>a HashSet of PlayListAsset objects</returns>
        private static HashSet <ContentPlaylistAsset> ConvertChannelAssetsToPlayListAssetsIfDateTimeDemoPermits(Channel channel,
                                                                                                                DemographicRangeVerifier demographicRangeVerifier, DateTime now)
        {
            HashSet <ContentPlaylistAsset> playlistAssets = new HashSet <ContentPlaylistAsset>();

            ContentPlaylistAsset playlistAsset = null;

            foreach (ChannelAsset chAsset in channel.ChannelAssets)
            {
                if (now >= chAsset.StartDateTime && now <= chAsset.EndDateTime &&
                    demographicRangeVerifier.IsAssetDemoSyntaxPlayable(chAsset.DemoRequirements))
                {
                    playlistAsset = new ContentPlaylistAsset
                    {
                        AssetID          = chAsset.AssetID,
                        AssetFilename    = chAsset.AssetFilename,
                        ClickDestination = chAsset.ClickDestination,
                        AssetWebSite     = chAsset.AssetWebSite,
                        DisplayLength    = chAsset.DisplayDuration,
                        PlayerType       = chAsset.PlayerType,
                        ScheduleInfo     = chAsset.ScheduleInfo,
                        AssetLevel       = chAsset.AssetLevel == ChannelDataAssetLevel.Normal ? PlaylistAssetLevel.Normal : PlaylistAssetLevel.Premium,
                        StartDateTime    = chAsset.StartDateTime,
                        EndDateTime      = chAsset.EndDateTime
                    };

                    playlistAssets.Add(playlistAsset);
                }
            }

            return(playlistAssets);
        }
Example #2
0
        public void IsAssetDemoSyntaxPlayableTest()
        {
            DemographicData          demographicData = null;
            DemographicRangeVerifier target          = new DemographicRangeVerifier(demographicData);

            string[] inputConditionCollection = null;
            bool     expected = false;
            bool     actual;

            actual = target.IsAssetDemoSyntaxPlayable(inputConditionCollection);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Example #3
0
        public void IsAssetDemoSyntaxPlayableTestSuccessfulConditionsExcludeIncludeSameMet()
        {
            DemographicData demographicData = new DemographicData();

            demographicData.SocioEconomicgroup = new string[] { "a1", "a2" };
            demographicData.MaxAge             = 35;
            demographicData.MinAge             = 30;
            demographicData.GeoDefinition      = "0.1.2";
            demographicData.Gender             = new string[] { "male" };

            DemographicRangeVerifier demographicRangeVerifier = new DemographicRangeVerifier(demographicData);

            string[] inputConditionCollection = new string[3];

            inputConditionCollection[0] = "age > 30 and gender=male and socioeconomicgroup=a2 and geo=0.1"; // will be met and excluded
            inputConditionCollection[1] = "age > 30 and gender=male and socioeconomicgroup=a2 and geo=0.1"; // will be met and excluded
            inputConditionCollection[2] = "age > 35 and gender=male and socioeconomicgroup=a2 and geo=0.3"; // will be not met and included

            bool expected = true;
            bool actual;

            actual = demographicRangeVerifier.IsAssetDemoSyntaxPlayable(inputConditionCollection);
            Assert.AreEqual(expected, actual, "Verify the correctness of this test method.");
        }
Example #4
0
        private static void GetAdvertisingPlaylist(string advertListPath, string demographicDataPath,
                                                   DemographicRangeVerifier demographicRangeVerifier, string password, Playlist playlist, ChannelData channelData,
                                                   ChannelSubscriptions channelSubscriptions, DateTime now, Logger logger)
        {
            // if the advertisment or the demographic data file is not found, an exception will be thrown
            // if user has corrupted any of the files, an exception will be thrown
            AdvertList advertList = (AdvertList)Serializer.Deserialize(typeof(AdvertList), advertListPath, password);

            // flatten channel definitions
            HashSet <string> channelDefinitions = new HashSet <string>();

            foreach (Channel channel in channelData.Channels)
            {
                SplitAndInsertChannelDefinitions(ref channelDefinitions, channel.ChannelDefinitions);
            }

            // flatten advert definitions
            HashSet <string> advertDefinitions = new HashSet <string>();

            foreach (AdvertAsset advertasset in advertList.Adverts)
            {
                SplitAndInsertChannelDefinitions(ref advertDefinitions, advertasset.AdvertDefinitions);
            }

            var advertListsFiltered = HashSetLinqAccess.ToHashSet <AdvertPlaylistAsset>(from AdvertAsset advertAsset in advertList.Adverts
                                                                                        where demographicRangeVerifier.IsAssetDemoSyntaxPlayable(advertAsset.DemoRequirements) &&
                                                                                        TreeSearch.IncludeByChannelClassifications(channelDefinitions, advertAsset.InclusionExclusionList) == true &&
                                                                                        TreeSearch.IncludeByAdvertClassifications(advertDefinitions, channelData, channelSubscriptions) == true &&
                                                                                        now >= advertAsset.StartDateTime &&
                                                                                        now <= advertAsset.EndDateTime
                                                                                        select new AdvertPlaylistAsset
            {
                AssetID               = advertAsset.AssetID,
                AssetFilename         = advertAsset.AssetFilename,
                ClickDestination      = advertAsset.ClickDestination,
                AssetWebSite          = advertAsset.AssetWebSite,
                PlayerType            = advertAsset.PlayerType,
                ScheduleInfo          = advertAsset.ScheduleInfo,
                DisplayLength         = advertAsset.DisplayDuration,
                WeightingUnnormalized = advertAsset.Weighting,
                StartDateTime         = advertAsset.StartDateTime,
                EndDateTime           = advertAsset.EndDateTime
            });

            playlist.AdvertBucket.AdvertAssets = advertListsFiltered;
        }