0

The code has usage of WebRequestContext.Localization.GetConfig("<module_name>.<key_name>") and it makes a problem during writing UnitTest. It is not a possibility to include that as a parameter in the call of the method from many reasons.

Is there any way to mock that WebRequestContext.Localization?

I checked Sdl.Web.Tridion.Tests which comes with DXA 2.2 solution, but didn't find it.

Update: Our implementation has in some of the method usages of WebRequestContext.Localization.GetConfig(".") and when we write our own Unit Test to test that Business Logic it fails since there is nothing for WebRequestContext.Localization.

0

Sdl.Web.Tridion.Tests contains unit/integration tests for (guess what...) Sdl.Web.Tridion, which is the Tridion provider and model mapping layer in the DXA web app architecture.

There are no unit tests for the Views/Controllers; those are tested by SDL using a suite of system tests, which test the entire web app (incl. modules) through HTTP.

| improve this answer | |
  • (guess what..) I know that. My purpose is not that. Our implementation has in some of the method usages of WebRequestContext.Localization.GetConfig("<module_name>.<key_name>") and when we write our own Unit Test to test that Business Logic it fails since there is nothing for WebRequestContext.Localization. So that's why I am asking if there is a way to support for unit test. – Ljiljana Eric May 8 at 9:26
  • I would recommend not to use WebRequestContext directly in Business Logic. Would it be an option to parameterize the Business Logic so it accepts a Localization? That would allow you to provide a (test) Localization in your unit tests. See also Sdl.Web.Tridion.Tests. – Rick Pannekoek May 8 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.