From 1a032d1f027a29e05cf2f4ac73a52fad6d4752bb Mon Sep 17 00:00:00 2001 From: Vit Nemecky Date: Fri, 9 May 2025 19:35:04 +0200 Subject: [PATCH 1/2] integration test images --- .../UI/Images/DeviceImagesResouceTests.cs | 46 ++++++++++++++++++ .../BrickController2/BrickController2.csproj | 13 ++--- .../Helpers/ResourceHelper.cs | 5 +- .../{infra_image.png => infrared_image.png} | Bin ...age_small.png => infrared_image_small.png} | Bin ...technic_move.png => technicmove_image.png} | Bin ..._small.png => technicmove_image_small.png} | Bin .../{wedo2hub_image.png => wedo2_image.png} | Bin ..._image_small.png => wedo2_image_small.png} | Bin 9 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 BrickController2/BrickController2.Tests/UI/Images/DeviceImagesResouceTests.cs rename BrickController2/BrickController2/UI/Images/{infra_image.png => infrared_image.png} (100%) rename BrickController2/BrickController2/UI/Images/{infra_image_small.png => infrared_image_small.png} (100%) rename BrickController2/BrickController2/UI/Images/{technic_move.png => technicmove_image.png} (100%) rename BrickController2/BrickController2/UI/Images/{technic_move_small.png => technicmove_image_small.png} (100%) rename BrickController2/BrickController2/UI/Images/{wedo2hub_image.png => wedo2_image.png} (100%) rename BrickController2/BrickController2/UI/Images/{wedo2hub_image_small.png => wedo2_image_small.png} (100%) diff --git a/BrickController2/BrickController2.Tests/UI/Images/DeviceImagesResouceTests.cs b/BrickController2/BrickController2.Tests/UI/Images/DeviceImagesResouceTests.cs new file mode 100644 index 00000000..b166935b --- /dev/null +++ b/BrickController2/BrickController2.Tests/UI/Images/DeviceImagesResouceTests.cs @@ -0,0 +1,46 @@ +using BrickController2.DeviceManagement; +using BrickController2.Helpers; +using FluentAssertions; +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace BrickController2.Tests.UI.Images; + +public class DeviceImagesResouceTests +{ + public static IEnumerable DeviceTypesData => + Enum.GetValues(typeof(DeviceType)) + .Cast() + .Where(deviceType => deviceType != DeviceType.Unknown) // Exclude Unknown + .Select(deviceType => new object[] { deviceType }); + + [Theory] + [MemberData(nameof(DeviceTypesData))] + public void GetImageResource_DeviceType_SmallImageExists(DeviceType deviceType) + { + var smallImageName = $"{deviceType.ToString().ToLower()}" + "_image_small.png"; + + AssertImageResourceExists(smallImageName); + } + + [Theory] + [MemberData(nameof(DeviceTypesData))] + public void GetImageResource_DeviceType_ImageExists(DeviceType deviceType) + { + var smallImageName = $"{deviceType.ToString().ToLower()}" + "_image.png"; + + AssertImageResourceExists(smallImageName); + } + + private static void AssertImageResourceExists(string immageName) + { + var fullResourceName = ResourceHelper.GetImageResourcePath(immageName); + + var resourceNames = typeof(ResourceHelper).Assembly.GetManifestResourceNames(); + var exists = resourceNames.Contains(fullResourceName); + + exists.Should().BeTrue(); + } +} diff --git a/BrickController2/BrickController2/BrickController2.csproj b/BrickController2/BrickController2/BrickController2.csproj index 1884547f..2395449a 100644 --- a/BrickController2/BrickController2/BrickController2.csproj +++ b/BrickController2/BrickController2/BrickController2.csproj @@ -12,6 +12,7 @@ + @@ -28,16 +29,16 @@ - - + + - - - - + + + + diff --git a/BrickController2/BrickController2/Helpers/ResourceHelper.cs b/BrickController2/BrickController2/Helpers/ResourceHelper.cs index 4af23f84..a50921fe 100644 --- a/BrickController2/BrickController2/Helpers/ResourceHelper.cs +++ b/BrickController2/BrickController2/Helpers/ResourceHelper.cs @@ -27,7 +27,10 @@ public static ResourceManager TranslationResourceManager public static ImageSource GetImageResource(string resourceName) { // define sourceAssembly parameter to avoid looking for assembly by Xamarin (via reflection of Assembly.GetCallingAssembly) - return ImageSource.FromResource($"{ImageResourceRootNameSpace}.{resourceName}", typeof(ResourceHelper).Assembly); + var resourcePath = GetImageResourcePath(resourceName); + return ImageSource.FromResource(resourcePath, typeof(ResourceHelper).Assembly); } + + public static string GetImageResourcePath(string resourceName) => $"{ImageResourceRootNameSpace}.{resourceName}"; } } diff --git a/BrickController2/BrickController2/UI/Images/infra_image.png b/BrickController2/BrickController2/UI/Images/infrared_image.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/infra_image.png rename to BrickController2/BrickController2/UI/Images/infrared_image.png diff --git a/BrickController2/BrickController2/UI/Images/infra_image_small.png b/BrickController2/BrickController2/UI/Images/infrared_image_small.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/infra_image_small.png rename to BrickController2/BrickController2/UI/Images/infrared_image_small.png diff --git a/BrickController2/BrickController2/UI/Images/technic_move.png b/BrickController2/BrickController2/UI/Images/technicmove_image.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/technic_move.png rename to BrickController2/BrickController2/UI/Images/technicmove_image.png diff --git a/BrickController2/BrickController2/UI/Images/technic_move_small.png b/BrickController2/BrickController2/UI/Images/technicmove_image_small.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/technic_move_small.png rename to BrickController2/BrickController2/UI/Images/technicmove_image_small.png diff --git a/BrickController2/BrickController2/UI/Images/wedo2hub_image.png b/BrickController2/BrickController2/UI/Images/wedo2_image.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/wedo2hub_image.png rename to BrickController2/BrickController2/UI/Images/wedo2_image.png diff --git a/BrickController2/BrickController2/UI/Images/wedo2hub_image_small.png b/BrickController2/BrickController2/UI/Images/wedo2_image_small.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/wedo2hub_image_small.png rename to BrickController2/BrickController2/UI/Images/wedo2_image_small.png From 6f5d164164f549e9561a0be6a72e00d8e0b60c3a Mon Sep 17 00:00:00 2001 From: Vit Nemecky Date: Mon, 16 Jun 2025 22:24:37 +0200 Subject: [PATCH 2/2] pfx update --- .../BrickController2/BrickController2.csproj | 4 ++-- .../{pfx_brick_image.png => pfxbrick_image.png} | Bin ...ick_image_small.png => pfxbrick_image_small.png} | Bin 3 files changed, 2 insertions(+), 2 deletions(-) rename BrickController2/BrickController2/UI/Images/{pfx_brick_image.png => pfxbrick_image.png} (100%) rename BrickController2/BrickController2/UI/Images/{pfx_brick_image_small.png => pfxbrick_image_small.png} (100%) diff --git a/BrickController2/BrickController2/BrickController2.csproj b/BrickController2/BrickController2/BrickController2.csproj index c3ef21ab..c8a394ac 100644 --- a/BrickController2/BrickController2/BrickController2.csproj +++ b/BrickController2/BrickController2/BrickController2.csproj @@ -24,8 +24,8 @@ - - + + diff --git a/BrickController2/BrickController2/UI/Images/pfx_brick_image.png b/BrickController2/BrickController2/UI/Images/pfxbrick_image.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/pfx_brick_image.png rename to BrickController2/BrickController2/UI/Images/pfxbrick_image.png diff --git a/BrickController2/BrickController2/UI/Images/pfx_brick_image_small.png b/BrickController2/BrickController2/UI/Images/pfxbrick_image_small.png similarity index 100% rename from BrickController2/BrickController2/UI/Images/pfx_brick_image_small.png rename to BrickController2/BrickController2/UI/Images/pfxbrick_image_small.png