Try our conversational search powered by Generative AI!

OrderContext.MetaDataContext is null


I am trying to write unit tests for my new payment provider, but I am finding that OrderContext.MetaDataContext is null.

I'm sure I'm missing something fairly simple, but cannot work out what it is.

Any help would be greatly appreciated.


Jun 25, 2013 12:56



When moving into unit test project you have to copy like Web.Config from your Web project to the unit test App.Config. Make sure that all Mediachase config files and other config files also goes into the Unit test project.

What I´m guessing is that you are missing some Config files and then you may not have initilized the Order context.



Jun 28, 2013 17:38

We also experienced issues with licensing (especially when you touch some of the meta data parts). Forgot the details but issue was either license issused based on IP or MAC didn't work in unit tests.

Jun 29, 2013 13:31

Hmm, I have run EpiServer Commerce within a Console Application, Unit test, totally outside the Context of the Commerce IIS web application. I don´t recall any issue except when you forget to copy config files, settings, license files etc or when a context isn´t initilized correctly.


If you want to go more into Unit Test with EpiServer you can take a look on these




Jun 29, 2013 20:50

You need two things.
1 . configs file should be with bin
2. SQL Context is null and you will need to set that. Pseudo code is like this

if sqlcontext is null

Initialize sqlcontext.

I hope this will help and solve the issue.


Jul 04, 2013 21:14

For anyone reading this, we've been working on a massive comemrce build and one of the better ways we found to test everythign was instead of trying to get things like the metadata context to workk under test.  We created wrappers for all the big parts of the system. It's not ideal but after you have wrappers fo the main components life gets a lot easer, I wrote about the experience here

How To Unit Test EpiServer Commerce

Edited, Oct 09, 2015 11:45
* 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.