EaseLibrary / Ease

EaseLib is a library to ease unit testing through IoC containers and Mocking
MIT License
12 stars 1 forks source link

INavigationParameters location + Prism 7.2 support changes #2

Open keozx opened 5 years ago

keozx commented 5 years ago

Hi @duanenewman testing this I found an issue trying to use the VerifyNavigation() saying

error CS7069: Reference to type 'INavigationParameters' claims it is defined in 'Prism', but it could not be found

Tried to use this I found in your blog

<PackageReference Include="Prism.Core"  GeneratePathProperty="true" Version="7.2.0.1347-pre" ExcludeAssets="Compile"/>
...
And...
      <Reference Include="Prism">
      <HintPath>$(PkgPrism_Core)lib\netstandard2.0\Prism.dll</HintPath>
    </Reference>

But still can't find it, any suggestions? though this should not be needed since is still same netstandard

Thanks!

keozx commented 5 years ago

Ouch, tracked down to this change in 7.2 Prism https://github.com/PrismLibrary/Prism/pull/1348 I'm starting to use some features of 7.2 so I'll investigate why this breaks netcoreapp project

keozx commented 5 years ago

Oh this should be just because you are using 7.1 on Ease.NUnit.DryIoc.PrismForms, so I need to take the source and make it target 7.2 because of this INavigationParameters change :)

keozx commented 5 years ago

Ok that worked, probably it would be a good a idea to have a pre-release nuget with the Prism 7.2-pre references? For now I forked and fixed here https://github.com/keozx/Ease

duanenewman commented 5 years ago

Another thing to be aware of, if you were using .NET framework for a Prism.Forms test project you may get the wrong Prism library (WPF version). Use .NET Core for the test app to get the netstandard version of the prism libraries. I'll take a look at your fork, and look into a pre-release build.

keozx commented 5 years ago

There is also an issue with Navigation in 7.2 :/ changed INavigationService methods to extensions of INavigationServiceExtensions https://github.com/PrismLibrary/Prism/commit/753fe5a04fc65b1c0d27f0d0b721e14a8d66a25f

Getting Exception thrown: 'System.InvalidCastException' in Prism.Forms.dll An exception of type 'System.InvalidCastException' occurred in Prism.Forms.dll but was not handled in user code Unable to cast object of type 'Castle.Proxies.INavigationServiceProxy' to type 'Prism.Navigation.IPlatformNavigationService'.

Looking into it...

keozx commented 5 years ago

Ok so I fixed it (for now) I'll leave this open in case I come across another issue, basically what happens is that internally while navigating is using the new interface IPlatformNavigationService due the alignment of APIs, I changed the mock registration like this:

OnINavigationServiceMockCreated = (m) => m.As<IPlatformNavigationService>(); RegisterMockType(() => OnINavigationServiceMockCreated);

For the VerifyNavigation methods I had to treat INavigationServic as IPlatformNavigationService

var navServiceMock = Mock.Get(ResolveType<INavigationService>()).As<IPlatformNavigationService>();

Because this interface does not provide the optional parameters for some reason had to add those to every method like:

navServiceMock.Verify(n => (n.NavigateAsync(path, It.IsAny<INavigationParameters>(), It.IsAny<bool>(), It.IsAny<bool>())), times);

With this the verifynavigation() now works I have also pushed these changes in the fork, I think this can be simplified somehow like having the optional parameters...

duanenewman commented 4 years ago

Upgrading the Prism (and other references) is on my short term list. Hoping to have a lot of updates coming soon.

Samit-BTE commented 4 years ago

It would be nice if you can upgrade to PRISM 8 preview, it has support for Xamarin 4.6 and a few of breaking changes.

duanenewman commented 4 years ago

once I get all the appveyor/build stuff figured out I may create a preview branch to build preview builds with support

chowarth commented 4 years ago

I believe now that #4 has been merged in, once a new version has been released, the workaround mentioned by @keozx above will no longer be necessary as all Prism navigation extension methods should now be supported out of the box.