uno.extensions icon indicating copy to clipboard operation
uno.extensions copied to clipboard

[Hosting][Documentation] Overview should have instructions on overriding services in UITests

Open Youssef1313 opened this issue 2 years ago • 7 comments

Scenario:

The app uses an implementation of a specific service that connects to a server. The developer wants to create a mock implementation for that service for purpose of service.

Youssef1313 avatar May 27 '23 11:05 Youssef1313

@nickrandolph I'm not sure if this is actually possible today. So, if not possible, consider this as a feature request rather than documentation request.

Youssef1313 avatar May 27 '23 11:05 Youssef1313

This is already possible. If you look at the ToDo sample, it has mock services for use during Dev/test.

nickrandolph avatar May 27 '23 12:05 nickrandolph

Cc @lukeblevins can we add this to the docs

nickrandolph avatar May 27 '23 12:05 nickrandolph

This is already possible. If you look at the ToDo sample, it has mock services for use during Dev/test.

I'm not able to find these mock services.

Youssef1313 avatar May 27 '23 13:05 Youssef1313

This is already possible. If you look at the ToDo sample, it has mock services for use during Dev/test.

I'm not able to find these mock services.

Here's where one of them is registered: https://github.com/unoplatform/uno.todo/blob/824c6c4cb54b19f9ae98164d975fa2551ec3bc96/src/ToDo/ServiceCollectionExtensions.cs#L23

GitHub
Uno Platform "Uno To Do" reference app. Contribute to unoplatform/uno.todo development by creating an account on GitHub.

nickrandolph avatar Jun 14 '23 14:06 nickrandolph

Oh I was looking in https://github.com/unoplatform/uno.extensions/tree/main/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/ToDo.

Though the current approach isn't too flexible. I'm looking for something more similar to https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests?view=aspnetcore-7.0#inject-mock-services

Youssef1313 avatar Jun 14 '23 14:06 Youssef1313

With some reflection, I achieved a similar result. I have not tested this for Uno host but for the generic host it works. @Youssef1313 I can share the code but it is in F# Unfortunately MS had not opened the necessary APIs to call them directly

xperiandri avatar Jul 13 '24 15:07 xperiandri