Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor unit tests to use mocks instead of a database #17

Open
cmshawns opened this issue Jan 27, 2014 · 4 comments

Comments

Projects
None yet
2 participants
@cmshawns
Copy link
Contributor

commented Jan 27, 2014

Testing against an actual database presents several problems, foremost of which are

  1. Each college has different data - and sometimes even uses that data in different ways.
  2. Performance.

While using mocks does not provide a comprehensive test (LINQ-to-Objects has some different behaviors than using LINQ w/ the Entity Framework) it can still provide a quick check of application logic.

Colleges should provide their own college-specific tests, against an actual database, in addition to the mocked tests provided.

@cmshawns

This comment has been minimized.

Copy link
Contributor Author

commented Feb 19, 2014

@jonathanwindle and I have moved a copy of the current, database-focused unit tests to a new repository: CtcOdsApiTests.

cmshawn pushed a commit to cmshawn/CtcApi that referenced this issue Feb 21, 2014

Upgraded to Entity Framework 6
Issue BellevueCollege#17
Specifically, 6.0.2. Also cleaned up various compiler warnings, etc.
@cmshawn

This comment has been minimized.

Copy link

commented Feb 21, 2014

After upgrading to EF6 I needed to change a few namespace references, but other than that it seems to have gone pretty smoothly. The commit referenced above compiles. Now begins the long process of replacing all the unit tests that currently hit a live database.

@cmshawns

This comment has been minimized.

Copy link
Contributor Author

commented Feb 23, 2014

Confirmed that no existing unit tests (against the database) fail due to the EF 6 upgrade (2 failed due to unexpected data, 1 timeout) - after adding the following line to the top of OdsContext::OnModelCreating()

// Disable default initializer, which tries to modify the database when this method runs.
Database.SetInitializer<OdsContext>(null);

I did not commit or push the new code to the main repository.

@cmshawn

This comment has been minimized.

Copy link

commented Feb 24, 2014

FYI, I am basing this work off of the article, Testing with a mocking framework (EF6 onwards).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.