This is a migrated thread and some comments may be shown as answers.
Unit Testing Question
1 Answer 29 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Top achievements
Rank 1
Chris asked on 15 Jan 2010, 09:38 PM
I seem to be having some problems getting things configured properly for unit testing.

I'm using VS unit test framework. I've read How to: Use OpenAccess ORM with Test Frameworks but my set up seems to be a bit different.  I have a BLL that does all the CRUD and other functionality. It is also where business objects have to be created so their values can be properly initalized.

I don't want any class other than the BLL to have to have any knowledge of OA, (other than using the Business Objects)  including creating an ObjectScopeProvider. I would, preferably, like the unit test to just create a new BLL and then go about using it.

Here is what is currently happening:
1. The unit test start.
2. The unit test tries to create a new BLL -> Dim bll As New psDataEntities.PsBllOpenAccess
3. The BLL's new is called and then the BLL tries to create a IObjectScope  ->Dim scope As Telerik.OpenAccess.IObjectScope = ObjectScopeProvider1.GetNewObjectScope
4. In the BLL project's ObjectScopeProvider1, GetObjectScope is called.
5. Eventually the Database function is called.  It is unable to create the database and on the line:
     theObjectScopeProvider1._myDatabase = Telerik.OpenAccess.Database.Get( "DatabaseConnection1" )

The metadata for the db at this point is:
    {"Telerik.OpenAccess: No enhanced assembly has been found for meta-data construction. This may be caused by a missing app.config file (use app.config as embedded resource then) or by an insufficient references section in the configuration file (add the referenced enhanced assemblies there too) or by a wrong enhancement setting; please check your configuration."}

I've tried every combination of:
1. enhancing the unit test to use Persistent Classes and/or Data Access Code
2. Setting the app.config for the unit test and bll to embedded resource or do nothing
3. Turning of Enhancing and Update Database setting for the unit test.

What are the proper settings?  Am I missing something more basic?
Any thoughts would be greatly appreciated

1 Answer, 1 is accepted

Sort by
Dimitar Kapitanov
Telerik team
answered on 21 Jan 2010, 07:20 AM
Hi Chris,
Because in the unit tests there is no assembly returned by Assembly.GetEntryAssembly(), can you please try to use the ObjectScopeProvider1.AdjustForDynamicLoad method before you call GetNewObjectsScope, and see whether this fixes the issue? If not maybe we will need a sample project (scaled-down) to overview the exact behavior.

Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Dimitar Kapitanov
Telerik team
Share this question