How to fake entity class

3 posts, 0 answers
  1. ari
    ari avatar
    20 posts
    Member since:
    Jun 2010

    Posted 05 Apr 2012 Link to this post

    Hi

    my tests fail

    code to test

     DHP_Document documentObject = ctx.DHP_Document.Single(d => d.DocumentID == document.DocumentID);

    documentObject    = null


    How I can  mock DHP_Document   which is entity table in database ?

    i have mocked  ctx.DHP_Document 
    Mock.Arrange(() => CustomerEntities.DHP_Document).ReturnsCollection(CreateDHP_DocumentList());

  2. Ricky
    Admin
    Ricky avatar
    467 posts

    Posted 09 Apr 2012 Link to this post

    Hi Ari,

    Thanks again for reporting the issue. If you have a sample project for the above exception then it will be a great starting point for debugging it further.

    However, you can also write your query in the following way:

    var document = (from dhp_doc in ctx.DHP_Document
    where dhp_doc.ID == document.ID
    select dhp_doc).Single();


    Kind Regards
    Mehfuz
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
  4. ari
    ari avatar
    20 posts
    Member since:
    Jun 2010

    Posted 10 Apr 2012 Link to this post

    hi 
    thanks it works now
Back to Top