Grial-UI-Kit-Support icon indicating copy to clipboard operation
Grial-UI-Kit-Support copied to clipboard

Grial 3.0 Mock Forms Cannot Initialize GrialKit Licensing

Open danstraughn opened this issue 5 years ago • 3 comments

Trying to write Unit Tests for the GrialKit 3.0 pages using Nunit, Moq and Xamarin Forms Mocks. On Init it is trying to register the init licensing for each platform specified but the license that is associated with each project is failing. The first items to fail is the light Theme with the following error: UXDivers.Grial.LicenseException : Grial UI Kit license not initialized, please call 'UXDivers.Grial.GrialKit.Init()' before performing the LoadApplication.

Steps to Reproduce

  1. Create NetCore 2.1 Nunit testing project with Moq, Nunit and Xam Mocks
  2. Write any unit test using Xamarin Forms Mocks
  3. Watch as tests fail immediately

Expected Behavior

Xamarin forms mocks would be able to test the pages associated no matter their dependencies, have no issues with SyncFusion or Telerik products. Grial checks licensing on each and every component including themes which is the only thing being used at the moment. The expected behavior is that one could write unit tests by calling some sort of Init that could be platform non-specific to enable page tests to be written.

Actual Behavior

The unit test bomb out and there is no getting passed the LicenseException because Grial checks for each project and each component for a license.

Basic Information

Latest version of everything Mac OSX, Xcode etc, details below.

=== Visual Studio Community 2019 for Mac ===

Version 8.1 (build 2742) Installation UUID: 23da0daf-8836-4036-ba27-7659408d944a GTK+ 2.24.23 (Raleigh theme) Xamarin.Mac 5.6.0.25 (d16-0 / 50f75273)

Package version: 518010028

=== Mono Framework MDK ===

Runtime: Mono 5.18.1.28 (2018-08/223ea7ef92e) (64-bit) Package version: 518010028

=== NuGet ===

Version: 5.0.2.5988

=== .NET Core ===

Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 2.1.11 2.1.9 2.1.8 SDK: /usr/local/share/dotnet/sdk/2.1.700/Sdks SDK Versions: 2.1.700 2.1.505 2.1.504 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.18.1/lib/mono/msbuild/Current/bin/Sdks

=== Xamarin.Profiler ===

Version: 1.6.10 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 10.2.1 (14490.122) Build 10E1001

=== Xamarin.Mac ===

Version: 5.10.0.153 (Visual Studio Community) Hash: 750a8798 Branch: d16-1-artifacts Build date: 2019-04-30 15:17:54-0400

=== Xamarin.iOS ===

Version: 12.10.0.153 (Visual Studio Community) Hash: 750a8798 Branch: d16-1-artifacts Build date: 2019-04-30 15:17:54-0400

=== Xamarin Designer ===

Version: 16.1.0.464 Hash: 66bb7b43f Branch: remotes/origin/d16-1-new-document-model Build date: 2019-06-07 07:10:32 UTC

=== Xamarin.Android ===

Version: 9.3.0.22 (Visual Studio Community) Commit: HEAD/8e7764fdf Android SDK: /Users/danielstraughn/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 8.1 (API level 27)

SDK Tools Version: 26.1.1 SDK Platform Tools Version: 29.0.1 SDK Build Tools Version: 28.0.3

Build Information: Mono: mono/mono/2018-08@3cb36842fc4 Java.Interop: xamarin/java.interop/d16-1@5ddc3e3 LibZipSharp: grendello/LibZipSharp/d16-1@44de300 LibZip: nih-at/libzip/rel-1-5-1@b95cf3f ProGuard: xamarin/proguard/master@905836d SQLite: xamarin/sqlite/3.27.1@8212a2d Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-1@acabd26

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/danielstraughn/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25 1.8.0-25 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

=== Android Device Manager ===

Version: 1.2.0.44 Hash: aac645b Branch: remotes/origin/d16-1 Build date: 2019-05-29 19:55:24 UTC

=== Xamarin Inspector ===

Version: 1.4.3 Hash: db27525 Branch: 1.4-release Build date: Mon, 09 Jul 2018 21:20:18 GMT Client compatibility: 1

=== Build Information ===

Release ID: 801002742 Git revision: ed27233de1b33083ea2234bc66a3b7824b99bbc7 Build date: 2019-06-12 10:18:51+00 Build branch: release-8.1 Xamarin extensions: 98dc4d7de2257c9b7342dee023910e16d02f8e65

=== Operating System ===

Mac OS X 10.14.5 Darwin 18.6.0 Darwin Kernel Version 18.6.0 Thu Apr 25 23:16:27 PDT 2019 root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

=== Enabled user installed extensions ===

Brute Clean 1.1 .NET Core support for Mono.Debugging 8.0.5 FileNesting 0.1.2 MSBuild Editor 2.2.0 NuGet Package Explorer 0.3.2 NuGet Package Management Extensions 0.19 Template Creator 0.4 Mutatio 1.0.3 DeepClean 1.2.5 XAML Styler 1.1.2

Screenshots

Screen Shot 2019-06-17 at 7 11 50 AM

danstraughn avatar Jun 17 '19 14:06 danstraughn

Anyone check in to this or have a work around? This is really effecting our devs.

danstraughn avatar Aug 18 '19 15:08 danstraughn

Hi @danstraughn. Please upgrade your UXDivers.Grial packages to version 3.0.49-RC. This version should overcome this limitation.

In addition to this, you will need to register a couple of Dependency Services Grial depends on, see below:

using System;
using System.Globalization;
using FFImageLoading;
using NUnit.Framework;
using UXDivers.Grial;
using Xamarin.Forms;

namespace Tests
{
    public class Tests
    {
        [SetUp]
        public void Setup()
        {
            ImageService.EnableMockImageService = true;
            Xamarin.Forms.Mocks.MockForms.Init();

            DependencyService.Register<ICultureServiceLocator, CultureServiceLocator>();
            DependencyService.Register<IDeviceOrientationServiceLocator, DeviceOrientationServiceLocator>();

            Application.Current = new Clayton.App();
        }

        [Test]
        public void Test1()
        {
            var page = new Clayton.WelcomeStarterPage();

            Assert.NotNull(page);
        }

        class CultureServiceLocator : ICultureServiceLocator
        {
            public ICultureService Service => new CultureService();

            class CultureService : ICultureService
            {
                public CultureInfo CurrentCulture => CultureInfo.CurrentCulture;

                public event CultureChangedEventHandler CurrentCultureChanged;

                public void SimulateCultureChange(CultureInfo ci)
                {
                }
            }
        }

        class DeviceOrientationServiceLocator : IDeviceOrientationServiceLocator
        {
            public IDeviceOrientation Service => new DeviceOrientationService();

            class DeviceOrientationService : IDeviceOrientation
            {
                public DeviceOrientation Orientation => DeviceOrientation.Portrait;

                public bool IsPortrait => true;

                public bool IsLandscape => false;

                public event EventHandler OrientationChanged;
            }
        }
    }
}

Please let me know how it goes.

LeoHere avatar Aug 20 '19 16:08 LeoHere

Thank you very much. I will update and let you know how it goes.

On Tue, Aug 20, 2019 at 9:52 AM Leo Rodríguez [email protected] wrote:

Hi @danstraughn https://github.com/danstraughn. Please upgrade your UXDivers.Grial packages to version 3.0.49-RC. This version should overcome this limitation.

In addition to this, you will need to register a couple of Dependency Services Grial depends on, see below:

using System; using System.Globalization; using FFImageLoading; using NUnit.Framework; using UXDivers.Grial; using Xamarin.Forms;

namespace Tests { public class Tests { [SetUp] public void Setup() { ImageService.EnableMockImageService = true; Xamarin.Forms.Mocks.MockForms.Init();

        DependencyService.Register<ICultureServiceLocator, CultureServiceLocator>();
        DependencyService.Register<IDeviceOrientationServiceLocator, DeviceOrientationServiceLocator>();

        Application.Current = new Clayton.App();
    }

    [Test]
    public void Test1()
    {
        var page = new Clayton.WelcomeStarterPage();

        Assert.NotNull(page);
    }

    class CultureServiceLocator : ICultureServiceLocator
    {
        public ICultureService Service => new CultureService();

        class CultureService : ICultureService
        {
            public CultureInfo CurrentCulture => CultureInfo.CurrentCulture;

            public event CultureChangedEventHandler CurrentCultureChanged;

            public void SimulateCultureChange(CultureInfo ci)
            {
            }
        }
    }

    class DeviceOrientationServiceLocator : IDeviceOrientationServiceLocator
    {
        public IDeviceOrientation Service => new DeviceOrientationService();

        class DeviceOrientationService : IDeviceOrientation
        {
            public DeviceOrientation Orientation => DeviceOrientation.Portrait;

            public bool IsPortrait => true;

            public bool IsLandscape => false;

            public event EventHandler OrientationChanged;
        }
    }
}

}

Please let me know how it goes.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/UXDivers/Grial-UI-Kit-Support/issues/587?email_source=notifications&email_token=AAR7ZQY36IIUPBF6M37QPHDQFQOM5A5CNFSM4HYXBSS2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD4W6IVY#issuecomment-523101271, or mute the thread https://github.com/notifications/unsubscribe-auth/AAR7ZQY2P7UQP4UGQAUOCZTQFQOM5ANCNFSM4HYXBSSQ .

-- Thanks, Daniel

danstraughn avatar Aug 20 '19 17:08 danstraughn