/// <summary> /// Asserts that the <paramref name="titleAsset"/> contains equivalent values from the <paramref name="serviceTitle"/>. /// </summary> /// <param name="serviceTitle">The title with expected values.</param> /// <param name="titleAsset">The title with actual values.</param> public static void AssertTitle(Title serviceTitle, TitleAsset titleAsset) { Assert.AreEqual(serviceTitle.Id, titleAsset.ProviderUri); Assert.AreEqual(serviceTitle.TextBlockCollection[0].Text, titleAsset.MainText); Assert.AreEqual(serviceTitle.TextBlockCollection[0].Text, titleAsset.SubText); AssertTitleTemplate(serviceTitle.TitleTemplate, titleAsset.TitleTemplate); }
/// <summary> /// Publish the <see cref="AddAssetToTimelineEvent"/> to add the asset in the timeline at the current playhead position. /// </summary> /// <param name="titleTemplate">Title template of the title asset to be added to timeline.</param> public void AddTitleAssetToTimeline(TitleTemplate titleTemplate) { TitleAsset titleAsset = CreateTitleAsset(titleTemplate); if (titleTemplate != null) { this.eventAggregator.GetEvent <AddAssetToTimelineEvent>().Publish(titleAsset); } }
/// <summary> /// Creates a title asset for testing. /// </summary> /// <returns>A title with values.</returns> public static TitleAsset CreateTitleAsset() { var title = new TitleAsset(); title.ProviderUri = CreateUri(); title.TitleTemplate = CreateTitleTemplate(); title.MainText = "MainText"; title.SubText = "SubText"; return(title); }
/// <summary> /// Creates a <see cref="TitleAsset"/> associated to the <see cref="TitleTemplate"/> passed. /// </summary> /// <param name="titleTemplate">The title template of the title asset being created.</param> /// <returns>A new title asset.</returns> private static TitleAsset CreateTitleAsset(TitleTemplate titleTemplate) { TitleAsset titleAsset = new TitleAsset { Title = titleTemplate.Title, MainText = titleTemplate.MainText, SubText = titleTemplate.SubText, TitleTemplate = titleTemplate }; return(titleAsset); }
/// <summary> /// Initializes a new instance of the <see cref="TitlePreview"/> class. /// </summary> /// <param name="asset">The asset.</param> public TitlePreview(TitleAsset asset) { // Required to initialize variables InitializeComponent(); if (asset == null) { throw new ArgumentNullException("asset"); } this.DataContext = asset; }
public void ShouldNotPublishShowMetadataEventWhenShowMetadataIsCalledAndAssetIsTitleAssest() { TitleAsset asset = new TitleAsset(); var presentationModel = this.CreatePresentationModel(); this.showMetadataEvent.PublishCalled = false; this.showMetadataEvent.Asset = null; presentationModel.ShowMetadata(asset); Assert.IsFalse(this.showMetadataEvent.PublishCalled); Assert.IsNull(this.showMetadataEvent.Asset); }
public void ShouldGetANewTitleAssetWhenSameValuesWhenCallingToClone() { var titleAsset = new TitleAsset { MainText = "MainText", SubText = "SubText", Source = new Uri("http://contoso.com"), }; var newTitleAsset = titleAsset.Clone(); Assert.AreEqual(titleAsset.Id, newTitleAsset.Id); Assert.AreEqual(titleAsset.MainText, newTitleAsset.MainText); Assert.AreEqual(titleAsset.SubText, newTitleAsset.SubText); Assert.AreEqual(titleAsset.Source, newTitleAsset.Source); Assert.AreNotSame(titleAsset, newTitleAsset); }
/// <summary> /// Initializes a new instance of the <see cref="TitlePlayer"/> class. /// </summary> /// <param name="asset">The asset.</param> public TitlePlayer(TitleAsset asset) { this.DataContext = asset; Canvas.SetZIndex(this, 5); if (asset.TitleTemplate.XamlResource == null) { IConfigurationService configurationService = ServiceLocator.Current.GetInstance(typeof(IConfigurationService)) as IConfigurationService; if (configurationService != null) { Downloader downloader = ServiceLocator.Current.GetInstance(typeof(Downloader)) as Downloader; if (downloader != null) { Uri xamlResource = configurationService.GetTitleTemplate(asset.TitleTemplate.Title); downloader.DownloadStringCompleted += (sender, e) => { TitleTemplate template = e.UserState as TitleTemplate; if (e.Error == null && template != null) { template.XamlResource = e.Result; this.LoadTitle(template.XamlResource); } }; downloader.DownloadStringAsync(xamlResource, asset.TitleTemplate); } } } else { this.LoadTitle(asset.TitleTemplate.XamlResource); } this.timer = new Storyboard(); this.timer.Completed += this.Timer_Completed; }
public void ShouldRaiseOnPropertyChangedEventWhenSubTextIsUpdated() { var propertyChangedRaised = false; string propertyChangedEventArgsArgument = null; var titleAsset = new TitleAsset { SubText = string.Empty }; titleAsset.PropertyChanged += (sender, e) => { propertyChangedRaised = true; propertyChangedEventArgsArgument = e.PropertyName; }; Assert.IsFalse(propertyChangedRaised); Assert.IsNull(propertyChangedEventArgsArgument); titleAsset.SubText = "SubText"; Assert.IsTrue(propertyChangedRaised); Assert.AreEqual("SubText", propertyChangedEventArgsArgument); }