I've been using TDD/SSR for a while. I'm trying to transition to BDD: context, becauseOf, and Asserts.
I'm using Rhino Mocks to isolate, and I'm struggling with syntax now. Here's what I've got so far (note: ContextSpecification class source):
public static class DocumentIdAdapterTests {
public class DocumentIdAdapterContext : ContextSpecification {
protected IDocumentIdAdapter _documentIdAdapter;
protected ISettings _settingsMock;
protected override void Context() {
_settingsMock = MockRepository.GenerateMock<ISettings>();
_documentIdAdapter = new DocumentIdAdapter(_settingsMock);
}
}
[TestClass]
public class when_single_document_url_is_created : DocumentIdAdapterContext {
protected override void BecauseOf() {
_settingsMock.Stub(x => x.DocumentServiceBaseUrl).Return("fooOutput");
_documentIdAdapter.GetDocumentServiceSingleDocumentUrl("fooInput");
}
[TestMethod]
public void the_settings_should_provide_the_document_service_base_url() {
_settingsMock.AssertWasCalled(x => { var ignored = x.DocumentServiceBaseUrl; });
}
}
}
Where am I supposed to setup my stubs? For example, where am I supposed to stub the value that the DocumentServiceBaseUrl property will return? I'm doing it in my BecauseOf method now, but should I be doing it in my Context method?