diff --git a/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml b/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml index d63a9225942f..875b150dc775 100644 --- a/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml +++ b/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml @@ -4,8 +4,8 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:UITests.Shared.Windows_ApplicationModel" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - mc:Ignorable="d" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:generic="using:System.Collections.Generic" + mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> @@ -13,26 +13,16 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml.cs b/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml.cs index f247fe76bd69..81397a9236e6 100644 --- a/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml.cs +++ b/src/SamplesApp/UITests.Shared/Windows_ApplicationModel/PackageTests.xaml.cs @@ -1,4 +1,6 @@ using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; using Uno.UI.Samples.Controls; using Windows.ApplicationModel; using Windows.System; @@ -13,31 +15,68 @@ public sealed partial class PackageTests : UserControl public PackageTests() { this.InitializeComponent(); - DisplayName = SafeSet(() => Package.Current.DisplayName); - var packageId = Package.Current.Id; - Architecture = SafeSet(() => packageId.Architecture); - FamilyName = SafeSet(() => packageId.FamilyName); - FullName = SafeSet(() => packageId.FullName); - Name = SafeSet(() => packageId.Name); - Publisher = SafeSet(() => packageId.Publisher); - PublisherId = SafeSet(() => packageId.PublisherId); - ResourceId = SafeSet(() => packageId.ResourceId); - Version = SafeSet(() => $"{packageId.Version.Major}.{packageId.Version.Minor}.{packageId.Version.Revision}.{packageId.Version.Build}"); + + AddProperties(Package.Current); } - private string SafeSet(Func propertyGetter) + public void AddProperties(Package package) + { + SafeAdd("DisplayName", () => package.DisplayName); + SafeAdd("Description", () => package.Description); + SafeAdd("EffectiveExternalLocation", () => package.EffectiveExternalLocation.Path); + SafeAdd("EffectiveExternalPath", () => package.EffectiveExternalPath); + SafeAdd("EffectiveLocation", () => package.EffectiveLocation.Path); + SafeAdd("EffectivePath", () => package.EffectivePath); + SafeAdd("Status", () => package.Status); + SafeAdd("PublisherDisplayName", () => package.PublisherDisplayName); + SafeAdd("InstallDate", () => package.InstallDate); + SafeAdd("InstalledDate", () => package.InstalledDate); + SafeAdd("InstalledLocation", () => package.InstalledLocation.Path); + SafeAdd("InstalledPath", () => package.InstalledPath); + SafeAdd("IsBundle", () => package.IsBundle); + SafeAdd("IsDevelopmentMode", () => package.IsDevelopmentMode); + SafeAdd("IsFramework", () => package.IsFramework); + SafeAdd("IsOptional", () => package.IsOptional); + SafeAdd("IsResourcePackage", () => package.IsResourcePackage); + SafeAdd("IsStub", () => package.IsStub); + SafeAdd("Logo", () => package.Logo); + SafeAdd("MachineExternalLocation", () => package.MachineExternalLocation.Path); + SafeAdd("MachineExternalPath", () => package.MachineExternalPath); + SafeAdd("MutableLocation", () => package.MutableLocation); + SafeAdd("MutablePath", () => package.MutablePath); + SafeAdd("SignatureKind", () => package.SignatureKind); + SafeAdd("UserExternalLocation", () => package.UserExternalLocation.Path); + SafeAdd("UserExternalPath", () => package.UserExternalPath); + SafeAdd("Id.Architecture", () => package.Id.Architecture); + SafeAdd("Id.FamilyName", () => package.Id.FamilyName); + SafeAdd("Id.FullName", () => package.Id.FullName); + SafeAdd("Id.Name", () => package.Id.Name); + SafeAdd("Id.Publisher", () => package.Id.Publisher); + SafeAdd("Id.PublisherId", () => package.Id.PublisherId); + SafeAdd("Id.ResourceId", () => package.Id.ResourceId); + SafeAdd("Id.Version", () => $"{package.Id.Version.Major}.{package.Id.Version.Minor}.{package.Id.Version.Revision}.{package.Id.Version.Build}"); + } + + public ObservableCollection Items { get; } = new ObservableCollection(); + + private void SafeAdd(string propertyName, Func propertyGetter) { try { - return propertyGetter()?.ToString() ?? "(null)"; + var value = propertyGetter()?.ToString() ?? "(null)"; + Items.Add(new PackageProperty(propertyName, value)); } catch (NotImplementedException) { - return "Not implemented"; + Items.Add(new PackageProperty(propertyName, "Not implemented")); + } + catch (NotSupportedException) + { + Items.Add(new PackageProperty(propertyName, "Not supported")); } catch (Exception ex) { - return $"Exception thrown - {ex.Message}"; + Items.Add(new PackageProperty(propertyName, $"Exception thrown - {ex.Message}")); } } @@ -61,4 +100,17 @@ private string SafeSet(Func propertyGetter) public string Version { get; } } + + public class PackageProperty + { + public PackageProperty(string name, string value) + { + Name = name; + Value = value; + } + + public string Name { get; } + + public string Value { get; } + } }