fitSharp
Domain Adapter
A domain adapter is a class that wraps a domain class and provides additional methods to enhance testability.

Most of the fixture classes that are derived from the standard fixtures are, in fact, domain adapters. However, providing the domain adapter role in a class that must be part of the fixture inheritance hierarchy can sometimes lead to code complexity or repetition.

Separate domain adapters can be written and used by the standard fixtures, without writing any fixture code. Methods of the domain adapter and methods of the domain class can both be used in story test tables. The domain adapter can be reused in a variety of tests.

A domain adapter class implements the Domain Adapter interface:
public interface DomainAdapter {
    object SystemUnderTest { get; }
}
public class SampleDomainAdapter: DomainAdapter {
    public SampleDomainAdapter() { myDomain = new SampleDomain(); }
    public object SystemUnderTest { get { return myDomain; } }
    public string LowerCaseName {get { return myDomain.Name.ToLower(); } }
    private SampleDomain myDomain;
}
public class SampleDomain {
    public string Name;
}
A domain adapter is created and automatically wrapped in a Do Fixture.
sample domain adapter

A method on the domain class is invoked.
setnameBob

A method on the domain adapter is invoked.
checklower case namebob

© Copyright Syterra Software Inc. All rights reserved.