locked
Is it possible to test Repository layer? RRS feed

  • Question

  • Hi,

    I am using EF + MSSQL. This is straight forward so that no reason to add more description.

    Best,

    Weera

    • Changed type Lisa Zhu Wednesday, February 27, 2013 6:05 AM
    • Moved by Lisa Zhu Wednesday, February 27, 2013 6:08 AM EF related
    Tuesday, February 26, 2013 12:27 PM

Answers

  • There is a post from Rowan Miller about faking a context here: http://romiller.com/2012/02/14/testing-with-a-fake-dbcontext/

    If you have created your own repository class to wrap the context then it might be easier to replace that rather than fake the context, but both should work.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Wednesday, February 27, 2013 5:59 PM

All replies

  • Hi Weera,

    As this is a EF related question, I will move it to ADO.NET Entity Framework and LINQ to Entities and change the type to question which make you get better support.

    Thanks for your support and understanding.

    Regards,


    Lisa Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 27, 2013 6:04 AM
  • Hi Weera,

    How do you test Repository layer? Unit test?

    Best Regards,


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, February 27, 2013 6:29 AM
  • There is a post from Rowan Miller about faking a context here: http://romiller.com/2012/02/14/testing-with-a-fake-dbcontext/

    If you have created your own repository class to wrap the context then it might be easier to replace that rather than fake the context, but both should work.


    We are seeing a lot of great Entity Framework questions (and answers) from the community on Stack Overflow. As a result, our team is going to spend more time reading and answering questions posted on Stack Overflow. We would encourage you to post questions on Stack Overflow using the entity-framework tag. We will also continue to monitor the Entity Framework forum.

    Wednesday, February 27, 2013 5:59 PM
  • On 2/27/2013 1:29 AM, Alexander Sun wrote:

    Hi Weera,



    How do you test Repository layer? Unit test?

    You can do an integration/functional test on the Repository classes that directly lead to accessing  the database through EF.

    Or you can do a unit test on the Repository classes and mockout methods that call to EF if the classes in the Repository are using Interfaces with using something like Rhinomocks or Moq framework.

    Thursday, February 28, 2013 2:46 AM