Creating the SUT Explicitly in developwithpassion.specifications

There will be times when you will want to explicilty specify how the SUT should be created when you are inheriting from either of the following classes:

  • Observes< SUT >
  • Observes< Contract , SUT >

To accomplish this you need to leverage the following block of code in the Establish block for your context:

1
  sut_factory.create_using(factory);

Factory will be of type SUTFactory which is bascially just a delegate type that takes no arguments and returns an instance of the system under test.

Most likely you will be using it as follows:

1
  sut_factory.create_using(() => new Calculator())

Hope this helps out!!

Develop With Passion®

Comments