Giter Site home page Giter Site logo

Comments (5)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
[deleted comment]

from sharp-architecture.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
Included Files:

    App.config
    CategoryRepositorySpecs.cs
    CategoryRepositoryTestsNew.cs
    DatabaseSpecBase.cs
    DatabaseUnitTestBase.cs
    hibernate.cfg.xml
    SpecExtensions.cs
    System.Data.SQLite.dll


Installation Instructions:

    0. Starting at Rev 73 (v 0.9.72):
    1. Add DatabaseUnitTestBase.cs and DatabaseSpecBase.cs to the NHibernate directory
of the SharpArch.Data project.
    2. Rebuild the SharpArch solution.
    3. Copy the newly compiled SharpArch.Data.dll file into the NorthwindSample/Solution
Items directory, overwriting the existing file.
    4. Copy the System.Data.SQLite.dll file into the NorthwindSample/Solution Items
directory.
    5. In the Northwind.Test project, add a reference to System.Data.SQLite.dll.
    6. Add the CategoryRepositoryTestsNew.cs and CategoryRepositorySpecs.cs files to the
NorthwindData directory of the Northwind.Tests project.
    7. Add the SpecExtensions.cs, hibernate.cfg.xml, and App.config (overwriting the
existing App.config) files to the root of the Northwind.Tests project.
    8. Set the "Copy to Output Directory" property of the hibernate.cfg.xml file to
"Copy Always".
    9. Rebuild the Northwind project and run the new unit tests.

Developer Notes:

    I created two different styles of in-memory database base classes:

    The first, DatabaseUnitTestBase, is based on a more traditional style of unit testing.

    The second, DatabaseSpecBase, allows you to do a BDD style testing, and is based on
this article - http://flux88.com/TheTransitionFromTDDToBDD.aspx - by Ben 
Scheirman.
Frankly, this approach can look either lame or like overkill when all your 
testing
are things like GetAll() and GetByID(). It really shines; however, when the 
single
method your testing has several requirements that need to be tested.

    The tests in CategoryRepositorySpecs.cs rely on extension methods in the
SpecExtensions.cs file. This file is from the CodeCampServer open source 
project (see
link at the top of the file) that is run by Jeffrey Palermo. I'd love to see
something like this incorporated into the SharpArch project, although I'm not 
exactly
sure where the file should go (it requires a reference to NUnit). These 
extensions
make for great test readability, especially if you're approaching testing from 
a BDD
mindset.

    One thing about testing against in-memory databases is that you have to load your
test data before doing any testing. At first this seemed like extra work, but I 
now
find that it adds tremendous clarity and portability to your tests.

    The code I wrote works, but I'm not sure if my use of the NHibernateSession class's
methods is correct, could you do a quick code review and let me know if anything
needs changing.

Follow Up:

    If you like, I can write some unit tests for the DatabaseUnitTestBase.cs and
DatabaseSpecBase.cs.

    If you like, I can rewrite some of the existing database tests using either or both
of these new base classes.

Original comment by [email protected] on 18 Nov 2008 at 4:33

Attachments:

from sharp-architecture.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
There's one thing about my solution that I don't like - Both DatabaseSpecBase
 and DatabaseUnitTestBase depend on NUnit - if you place them in the SharpArch.Data
project, then the project needs a reference to Nunit, which somehow seems out 
of place.

How about creating a new, separate SharpArch.Testing project for all of these
test-related classes (including SpecExtensions)? Conceptually it seems cleaner.

One more change: DatabaseSpecBase contains a When() method - I vote for 
changing the
name to Act(). I think it improves readability, especially when using class or
namespace names like "when_updating_a_product()" - it's a little jarring to see
"when_" and then "When". Naming it "Act()" also ties in nicely to the
Arrange/Act/Assert convention.

Original comment by [email protected] on 21 Nov 2008 at 11:18

from sharp-architecture.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
I've added all of this to my local development environment and it's working 
great.  
This is terrific work!  Could you please provide unit tests for 
DatabaseUnitTestBase 
and DatabaseSpecBase?

Original comment by [email protected] on 26 Nov 2008 at 2:07

  • Changed state: Started

from sharp-architecture.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 2, 2024
Thanks again for the help Lee...this was truly an awesome addition to the 
architecture!!

Original comment by [email protected] on 4 Dec 2008 at 3:16

  • Changed state: Fixed

from sharp-architecture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.