{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"never","basic_auth":false,"params":[],"results":{"codes":[]},"try":true},"next":{"description":"","pages":[]},"title":"The System Under Test (SUT)","type":"basic","slug":"the-system-under-test-sut","excerpt":"","body":"The System Under Test is the class you are testing.  SpecsFor will automatically create an instance of this class for you and store it in a property named SUT.  You can access this object at any phase of the [SpecsFor lifecycle](doc:specsfor-lifecycle) after InitializeClassUnderTest has been executed. \n\nYou tell SpecsFor what your System Under Test is going to be by specifying it as the type parameter when you derived from the SpecsFor<T> base class.  Whatever you specify for T becomes your System Under Test. \n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"\\t\\tpublic class given_a_car_is_started_when_a_car_is_stopped : SpecsFor<Car>\\n\\t\\t{\\n\\t\\t\\tprotected override void Given()\\n\\t\\t\\t{\\n\\t\\t\\t\\t//Given: establish state, in this case, that the car is started.\\n\\t\\t\\t\\tSUT.Start();\\n\\t\\t\\t}\\n\\n\\t\\t\\tprotected override void When()\\n\\t\\t\\t{\\n\\t\\t\\t\\t//When: perform an action, in this case, stopping the car.\\n\\t\\t\\t\\tSUT.Stop();\\n\\t\\t\\t}\\n\\n\\t\\t\\t//Note that there can be (and usually are) multiple 'Then' test cases.\\n\\t\\t\\t[Test]\\n\\t\\t\\tpublic void then_the_car_is_stopped()\\n\\t\\t\\t{\\n\\t\\t\\t\\t//Then: the car is stopped.\\n\\t\\t\\t\\tSUT.IsStopped.ShouldBeTrue();\\n\\t\\t\\t}\\n\\n\\t\\t\\t[Test]\\n\\t\\t\\tpublic void then_the_engine_is_stopped()\\n\\t\\t\\t{\\n\\t\\t\\t\\t//Then: the engine is stopped.\\n\\t\\t\\t\\tSUT.Engine.IsStopped.ShouldBeTrue();\\n\\t\\t\\t}\\n\\t\\t}\",\n      \"language\": \"csharp\"\n    }\n  ]\n}\n[/block]\nWhen SpecsFor creates your SUT, it automatically creates mock objects for any mockable dependencies.  See [SpecsFor and mocking](doc:specsfor-and-mocking) for more information.","updates":[],"order":2,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"547c7c5f78fd57080023c99c","version":{"version":"1.0","version_clean":"1.0.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["54471fc9e12a270800028ae0","5447b9e7b96a63140077d747","5447be130319802200fc0620","5447ed118d7af31a00dd411c","5447ed230319802200fc0702","5448524c4544c30800241f41","544854504544c30800241f4d","544854af4544c30800241f50","544854e74544c30800241f51","54485557c1b42e08005b82bf"],"_id":"54471fc9e12a270800028adf","__v":10,"project":"54471fc9e12a270800028adc","releaseDate":"2014-10-22T03:08:57.750Z","createdAt":"2014-10-22T03:08:57.750Z"},"__v":2,"createdAt":"2014-12-01T14:34:07.423Z","project":"54471fc9e12a270800028adc","user":"54471f91beb6320800da6f75","category":{"sync":{"isSync":false,"url":""},"pages":["544853a8c1b42e08005b82b6","5447ecac8d7af31a00dd4119","5447ed6d0319802200fc0705","5447ef7a8d7af31a00dd4125","54485217c1b42e08005b82a6","5448536e4544c30800241f48","54485396c1b42e08005b82b2","547c7c5f78fd57080023c99c"],"title":"Basics","slug":"basics","order":2,"from_sync":false,"reference":false,"_id":"544854e74544c30800241f51","project":"54471fc9e12a270800028adc","version":"54471fc9e12a270800028adf","createdAt":"2014-10-23T01:07:51.270Z","__v":1},"githubsync":""}

The System Under Test (SUT)


The System Under Test is the class you are testing. SpecsFor will automatically create an instance of this class for you and store it in a property named SUT. You can access this object at any phase of the [SpecsFor lifecycle](doc:specsfor-lifecycle) after InitializeClassUnderTest has been executed. You tell SpecsFor what your System Under Test is going to be by specifying it as the type parameter when you derived from the SpecsFor<T> base class. Whatever you specify for T becomes your System Under Test. [block:code] { "codes": [ { "code": "\t\tpublic class given_a_car_is_started_when_a_car_is_stopped : SpecsFor<Car>\n\t\t{\n\t\t\tprotected override void Given()\n\t\t\t{\n\t\t\t\t//Given: establish state, in this case, that the car is started.\n\t\t\t\tSUT.Start();\n\t\t\t}\n\n\t\t\tprotected override void When()\n\t\t\t{\n\t\t\t\t//When: perform an action, in this case, stopping the car.\n\t\t\t\tSUT.Stop();\n\t\t\t}\n\n\t\t\t//Note that there can be (and usually are) multiple 'Then' test cases.\n\t\t\t[Test]\n\t\t\tpublic void then_the_car_is_stopped()\n\t\t\t{\n\t\t\t\t//Then: the car is stopped.\n\t\t\t\tSUT.IsStopped.ShouldBeTrue();\n\t\t\t}\n\n\t\t\t[Test]\n\t\t\tpublic void then_the_engine_is_stopped()\n\t\t\t{\n\t\t\t\t//Then: the engine is stopped.\n\t\t\t\tSUT.Engine.IsStopped.ShouldBeTrue();\n\t\t\t}\n\t\t}", "language": "csharp" } ] } [/block] When SpecsFor creates your SUT, it automatically creates mock objects for any mockable dependencies. See [SpecsFor and mocking](doc:specsfor-and-mocking) for more information.