Unit Testing Question

Thread is closed for posting
2 posts, 0 answers
  1. Chris
    Chris avatar
    23 posts
    Member since:
    Feb 2009

    Posted 15 Jan 2010 Link to this post

    Hi,
    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
    Thanks.
  2. Dimitar Kapitanov
    Admin
    Dimitar Kapitanov avatar
    632 posts

    Posted 21 Jan 2010 Link to this post

    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.

    Greetings,
    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.
Back to Top