private static void AssertAdaptiveChildInTile(string expectedAdaptiveChildXml, IAdaptiveChild child) { var content = new TileContent() { Visual = new TileVisual() { TileMedium = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { (ITileBindingContentAdaptiveChild)child } } } } }; string expectedFinalXml = "<tile><visual><binding template='TileMedium'>" + expectedAdaptiveChildXml + "</binding></visual></tile>"; AssertHelper.AssertTile(expectedFinalXml, content); }
public void TestWeatherTile() { var backgroundImage = BackgroundImageMostlyCloudy; int overlay = 30; TileBindingContentAdaptive smallContent = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, HintOverlay = overlay }, Children = { new AdaptiveText() { Text = "Mon", HintStyle = AdaptiveTextStyle.Body, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = "63°", HintStyle = AdaptiveTextStyle.Base, HintAlign = AdaptiveTextAlign.Center } } }; TileBindingContentAdaptive mediumContent = new TileBindingContentAdaptive() { BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, HintOverlay = overlay }, Children = { new AdaptiveGroup() { Children = { GenerateMediumSubgroup("Mon", ImageMostlyCloudy, 63, 42), GenerateMediumSubgroup("Tue", ImageCloudy, 57, 38) } } } }; TileBindingContentAdaptive wideContent = new TileBindingContentAdaptive() { BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, HintOverlay = overlay }, Children = { new AdaptiveGroup() { Children = { GenerateWideSubgroup("Mon", ImageMostlyCloudy, 63, 42), GenerateWideSubgroup("Tue", ImageCloudy, 57, 38), GenerateWideSubgroup("Wed", ImageSunny, 59, 43), GenerateWideSubgroup("Thu", ImageSunny, 62, 42), GenerateWideSubgroup("Fri", ImageSunny, 71, 66) } } } }; TileBindingContentAdaptive largeContent = new TileBindingContentAdaptive() { BackgroundImage = new TileBackgroundImage() { Source = backgroundImage, HintOverlay = overlay }, Children = { new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 30, Children = { new AdaptiveImage() { Source = ImageMostlyCloudy } } }, new AdaptiveSubgroup() { Children = { new AdaptiveText() { Text = "Monday", HintStyle = AdaptiveTextStyle.Base }, new AdaptiveText() { Text = "63° / 42°" }, new AdaptiveText() { Text = "20% chance of rain", HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText() { Text = "Winds 5 mph NE", HintStyle = AdaptiveTextStyle.CaptionSubtle } } } } }, // For spacing new AdaptiveText(), new AdaptiveGroup() { Children = { GenerateLargeSubgroup("Tue", ImageCloudy, 57, 38), GenerateLargeSubgroup("Wed", ImageSunny, 59, 43), GenerateLargeSubgroup("Thu", ImageSunny, 62, 42), GenerateLargeSubgroup("Fri", ImageSunny, 71, 66) } } } }; TileContent content = new TileContent() { Visual = new TileVisual() { DisplayName = "Seattle", TileSmall = new TileBinding() { Content = smallContent }, TileMedium = new TileBinding() { Content = mediumContent, Branding = TileBranding.Name }, TileWide = new TileBinding() { Content = wideContent, Branding = TileBranding.NameAndLogo }, TileLarge = new TileBinding() { Content = largeContent, Branding = TileBranding.NameAndLogo } } }; string expectedPayload = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual displayName=""Seattle""><binding template=""TileSmall"" hint-textStacking=""center"">{GenerateStringBackgroundImage()}<text hint-align=""center"" hint-style=""body"">Mon</text><text hint-align=""center"" hint-style=""base"">63°</text></binding><binding template=""TileMedium"" branding=""name"">{GenerateStringBackgroundImage()}<group>"; // Medium tile subgroups expectedPayload += GenerateStringMediumSubgroup("Mon", ImageMostlyCloudy, 63, 42); expectedPayload += GenerateStringMediumSubgroup("Tue", ImageCloudy, 57, 38); expectedPayload += "</group></binding>"; // Wide tile expectedPayload += @"<binding template=""TileWide"" branding=""nameAndLogo"">"; expectedPayload += GenerateStringBackgroundImage(); expectedPayload += "<group>"; // Wide tile subgroups expectedPayload += GenerateStringWideSubgroup("Mon", ImageMostlyCloudy, 63, 42); expectedPayload += GenerateStringWideSubgroup("Tue", ImageCloudy, 57, 38); expectedPayload += GenerateStringWideSubgroup("Wed", ImageSunny, 59, 43); expectedPayload += GenerateStringWideSubgroup("Thu", ImageSunny, 62, 42); expectedPayload += GenerateStringWideSubgroup("Fri", ImageSunny, 71, 66); expectedPayload += "</group></binding>"; // Large tile expectedPayload += @"<binding template=""TileLarge"" branding=""nameAndLogo"">"; expectedPayload += GenerateStringBackgroundImage(); expectedPayload += $@"<group><subgroup hint-weight=""30""><image src=""{ImageMostlyCloudy}"" /></subgroup><subgroup><text hint-style=""base"">Monday</text><text>63° / 42°</text><text hint-style=""captionSubtle"">20% chance of rain</text><text hint-style=""captionSubtle"">Winds 5 mph NE</text></subgroup></group>"; expectedPayload += "<text />"; expectedPayload += "<group>"; // Large tile subgroups expectedPayload += GenerateStringLargeSubgroup("Tue", ImageCloudy, 57, 38); expectedPayload += GenerateStringLargeSubgroup("Wed", ImageSunny, 59, 43); expectedPayload += GenerateStringLargeSubgroup("Thu", ImageSunny, 62, 42); expectedPayload += GenerateStringLargeSubgroup("Fri", ImageSunny, 71, 66); expectedPayload += "</group></binding></visual></tile>"; AssertHelper.AssertTile(expectedPayload, content); }
public void TestMailTile() { TileBinding small = new TileBinding() { Content = new TileBindingContentIconic() { Icon = new TileBasicImage() { Source = "Assets\\Mail.png" } } }; TileBinding medium = new TileBinding() { Branding = TileBranding.Logo, Content = new TileBindingContentAdaptive() { Children = { GenerateFirstMessage(false), GenerateSpacer(), GenerateSecondMessage(false) } } }; TileBinding wideAndLarge = new TileBinding() { Branding = TileBranding.NameAndLogo, Content = new TileBindingContentAdaptive() { Children = { GenerateFirstMessage(true), GenerateSpacer(), GenerateSecondMessage(true) } } }; TileContent content = new TileContent() { Visual = new TileVisual() { TileSmall = small, TileMedium = medium, TileWide = wideAndLarge, TileLarge = wideAndLarge } }; string expectedXml = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual><binding template=""TileSquare71x71IconWithBadge""><image id=""1"" src=""Assets\Mail.png"" /></binding>"; // Medium expectedXml += @"<binding template=""TileMedium"" branding=""logo"">"; expectedXml += GenerateXmlGroups(false); expectedXml += "</binding>"; // Wide expectedXml += @"<binding template=""TileWide"" branding=""nameAndLogo"">"; expectedXml += GenerateXmlGroups(true); expectedXml += "</binding>"; // Large expectedXml += @"<binding template=""TileLarge"" branding=""nameAndLogo"">"; expectedXml += GenerateXmlGroups(true); expectedXml += "</binding>"; expectedXml += "</visual></tile>"; AssertHelper.AssertTile(expectedXml, content); }
public void TestXboxModernTile() { TileBinding medium = new TileBinding() { Content = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new AdaptiveText() { Text = "Hi,", HintStyle = AdaptiveTextStyle.Base, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = "MasterHip", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintAlign = AdaptiveTextAlign.Center } } } }; TileBinding wide = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 33, Children = { new AdaptiveImage() { Source = "http://xbox.com/MasterHip/profile.jpg", HintCrop = AdaptiveImageCrop.Circle } } }, new AdaptiveSubgroup() { HintTextStacking = AdaptiveSubgroupTextStacking.Center, Children = { new AdaptiveText() { Text = "Hi,", HintStyle = AdaptiveTextStyle.Title }, new AdaptiveText() { Text = "MasterHip", HintStyle = AdaptiveTextStyle.SubtitleSubtle } } } } } } } }; TileBinding large = new TileBinding() { Content = new TileBindingContentAdaptive() { TextStacking = TileTextStacking.Center, Children = { new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 1 }, new AdaptiveSubgroup() { HintWeight = 2, Children = { new AdaptiveImage() { Source = "http://xbox.com/MasterHip/profile.jpg", HintCrop = AdaptiveImageCrop.Circle } } }, new AdaptiveSubgroup() { HintWeight = 1 } } }, new AdaptiveText() { Text = "Hi,", HintStyle = AdaptiveTextStyle.Title, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = "MasterHip", HintStyle = AdaptiveTextStyle.SubtitleSubtle, HintAlign = AdaptiveTextAlign.Center } } } }; TileContent content = new TileContent() { Visual = new TileVisual() { Branding = TileBranding.NameAndLogo, TileMedium = medium, TileWide = wide, TileLarge = large } }; string expectedXml = $@"<?xml version=""1.0"" encoding=""utf-8""?><tile><visual branding=""nameAndLogo"">"; // Medium expectedXml += @"<binding template=""TileMedium"" hint-textStacking=""center""><text hint-align=""center"" hint-style=""base"">Hi,</text><text hint-align=""center"" hint-style=""captionSubtle"">MasterHip</text></binding>"; // Wide expectedXml += @"<binding template=""TileWide""><group><subgroup hint-weight=""33""><image src=""http://xbox.com/MasterHip/profile.jpg"" hint-crop=""circle"" /></subgroup><subgroup hint-textStacking=""center""><text hint-style=""title"">Hi,</text><text hint-style=""subtitleSubtle"">MasterHip</text></subgroup></group></binding>"; // Large expectedXml += @"<binding template=""TileLarge"" hint-textStacking=""center""><group><subgroup hint-weight=""1"" /><subgroup hint-weight=""2""><image src=""http://xbox.com/MasterHip/profile.jpg"" hint-crop=""circle"" /></subgroup><subgroup hint-weight=""1"" /></group><text hint-align=""center"" hint-style=""title"">Hi,</text><text hint-align=""center"" hint-style=""subtitleSubtle"">MasterHip</text></binding>"; expectedXml += "</visual></tile>"; AssertHelper.AssertTile(expectedXml, content); }