Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3966814
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T03:38:46+00:00 2026-05-20T03:38:46+00:00

I would like to start with integration testing. I am using an ASP.NET MVC

  • 0

I would like to start with integration testing. I am using an ASP.NET MVC 3 app. And I am using Entity Framework 4 Code First CTP5. My integration tests to the database is in a separate project something like MyProject.Data.IntegrationTests.

I am planning on using SQL Server CE 4 or SQLite. Any recommendations/tips/opinions on using any one of these for what I am trying to accomplish?

Does anyone know of any decent articles that I can read on what I am trying to accomplish? And help/feedback would be appreciated.

I am using SQL Server 2008 for my database. But when testing my repositories I would like to test them against one of these database mentioned above, so I will need to specify the connection string.

UPDATE

I work from a service layer (called from my controller) and then the service layer will call my repository. For examples, below is how I would add a news item:

Service class:

public class NewsService : INewsService
{
   private INewsRepository newsRepository;

   public NewsService(INewsRepository newsRepository)
   {
      this.newsRepository = newsRepository;
   }

   public News Insert(News news)
   {
      // Insert news item
      News newNews = newsRepository.Insert(news);

      // Insert audit entry

      // Return the inserted news item's unique identifier
      return newNews;
   }
}

Repository class:

public class NewsRepository : INewsRepository
{
   MyContext context = new MyContext();

   public NewsRepository()
   {
   }

   public News Insert(News news)
   {
      int newsId = context.Database.SqlQuery<int>("News_Insert @Title, @Body, @Active",
         new SqlParameter("Title", news.Title),
         new SqlParameter("Body", news.Body),
         new SqlParameter("Active", news.Active)
      ).FirstOrDefault();

      news.NewsId = newsId;

      // Return the inserted news item
      return news;
   }
}

I am using Entity Framework 4 Code First CTP5 and NUnit. Does NUnit has something similar to the roll back in XUnit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T03:38:47+00:00Added an answer on May 20, 2026 at 3:38 am

    If you use a testing framework like XUnit (http://xunit.codeplex.com/), it comes with a feature called [AutoRollback] and that will rollback the transaction ran in the test so none of your data will change!

    As far as how to setup the tests, I need to see more of how you setup your data access. Did you use the Repository Pattern? (Entity Framework 4 CTP 4 / CTP 5 Generic Repository Pattern and Unit Testable). If I could see some of your code it would help. Below is a sample integration test with XUnit:

    private readonly IUserRepository _repository;
    
    public UserRepositoryTests()
    {
        _repository = new UserRepository(base._databaseFactory);
    }
        
    [Fact, AutoRollback]
    public void Should_be_able_to_add_user()
    {
        var user = new User{Name = "MockName"};
        _repository.Add(user);
        base._unitOfWork.Commit();
        
        Assert.True(user.Id > 0);
    }
    

    So the above test adds a user to my database, then checks its Id property to check that SQL Server auto generated an Id for it. Because the method is decorated with the AutoRollback attribute, the data is then removed from my database after the method ends!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to start using Django with MYSQL, instead of sqlite all the
I am tasked to improve quality and implement TeamCity for continuous integration. My experience
I was doing some cross browser testing on certain piece of functionality today, and
I am writing a bunch of integration tests for a project. I want to
The followings are ok now: I have a multi-module project in maven with EJB
I am trying to change the layout content in my controller, which only seems
I'm looking for a good modeling tool to use for designing java applications that
I run a small Domain & webhosting reseller business. recently, my upstream Provider has
We have a huge amount of htmlsuite deisgned by business analyst and we want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.