Try our conversational search powered by Generative AI!

OrderContext.MetaDataContext is null

Vote:
 

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.

Thanks

#72641
Jun 25, 2013 12:56
Vote:
 

Hello!

 

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.

 

/M

#72786
Jun 28, 2013 17:38
Vote:
 

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.

#72795
Jun 29, 2013 13:31
Vote:
 

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

 

http://etf.codeplex.com/

http://tedgustaf.com/blog/2010/8/unit-test-an-episerver-6-website-using-visual-studio-2010-and-mstest/

 

/M

 

#72797
Jun 29, 2013 20:50
Vote:
 

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.

Regards
/K

#73062
Jul 04, 2013 21:14
Vote:
 

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

#139903
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.