AI OnAI Off
It is the generic variant of TryGetExistingInstance that is an extension method. It will call the non-generic variant which you can mock. Something like:
var providerBasedLocalizationService = new ProviderBasedLocalizationService(); object untypedLocalizationService = providerBasedLocalizationService; providerBasedLocalizationService.AddProvider(new MemoryLocalizationProvider()); serviceLocator.Setup(l => l.GetInstance<LocalizationService>()).Returns(providerBasedLocalizationService); serviceLocator.Setup(l => l.TryGetExistingInstance(typeof(LocalizationService), out untypedLocalizationService )).Returns(true);
Hi,
We have been able to mock the localization service with this code:
However this is not working as of Episerver 11 since TryGetExistingInstance is now an extension method. This wouldn't have been an issue if it wasn't that LocalizationService.Current is using this method, otherwise we could've just removed that setup.
To mitigate this problem I've replaced all our code calling LocalizationService.Current, but it seems like this code is also called internally by Episerver, e.g. by localized category descriptions.
How can we fix this?