volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

Unit Testing LocalizationService.GetString via MemoryLocalizationService

Hello.

I'm trying to unit test the LocalizationService.GetString. I'm using the Moq framework to create mocks of a class with a method I want to test (the target).

the target method I am testing uses the following LocalizationService code:

LocalizationService.Current.GetStringByCulture("sampleKey", cultureInfo)

I've read that you can unit test this with the MemoryLocalizationService class. In my unit test class I have the following code:

var memoryLocalizationService = new MemoryLocalizationService();
memoryLocalizationService.AddString(cultureInfo, "sampleKey", "textIWantToReceive");

I don't know where to go from here and I'm not able to find any examples online. How do I setup the LocalizationService to receive the dictionary from MemoryLocalizationService?

Thanks.

#178207
May 04, 2017 16:33
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.