I am using TDD / for a while. I am trying to make changes in BDD: References, Reasons, and Relatives
I am using Rhino Mox to separate, and now I am struggling with syntax. Even what I have achieved (note :):
Public Static Class DocumentIdAdapterTests {Public class DocumentIdAdapterContext: ContextSpecification {protected IDocumentIdAdapter _documentIdAdapter; Protected ISettings _settingsMock; Safe Override Zero Context () {_settingsMock = MockRepository.GenerateMock & lt; ISettings & gt; (); _documentIdAdapter = New DocumentIdAdapter (_settingsMock); }} [Test class] public class when_single_document_url_is_created: DocumentIdAdapterContext {due to safe override zero () {_settingsMock.Stub (x = & gt; x.DocumentServiceBaseUrl). Return ("fooOutput"); _documentIdAdapter.GetDocumentServiceSingleDocumentUrl ("fooInput"); } [TestMethod] Public Zero the_settings_should_provide_the_document_service_base_url () {_settingsMock.AssertWasCalled (x = & gt; {var ignored = x.DocumentServiceBaseUrl;}); }}}
Where are I supposed to set up my stubbs? For example, where can I believe the source of the document service service will return? I am doing it in my reason, but should I do it in my context?
It depends on which references affect your class behavior, and what your class Are just necessary for.
If you always start with specific references (for example, your document service is always located at a specific URL), you can set it up in the constructor or setup method.
If in your context that affects your behavior (which you say because OFF) then each context will require a new scenario. This is usually what the scenario is - the output of different results Combination of references (Asset).
A good BDD trick is to see different references. Think, "Will my code always behave like this? Is there any reference that produces a different result?" This gives you a good start-up conversation to know nothing about your code, and allows you to provide examples (unit tests) for each new aspect of behavior.
Comments
Post a Comment