Testable code
Fakes, Mocks, Stubs
Mocking
SUT
EXECUTE
DEP1
DEP2
SUT
EXECUTE
FAKE1
FAKE2
// Bad code (strong dependency)
public Card[] Cards { get; private set; }
// Good code
public IList<ICard> Cards { get; private set; }
// Even better, depends on what we need
public ICollection<ICard> Cards { get; private set; }
public interface IViewBase {}
public interface IPresenterBase {}
public class MemoryLayoutView : IViewBase {}
public class MemoryLayoutPresenter : IPresenterBase
{
private MemoryLayoutView view = new MemoryLayoutView();
public MemoryLayoutPresenter() { }
}
public interface IViewBase {}
public interface IPresenterBase {}
public class MemoryLayoutView : IViewBase {}
public class MemoryLayoutPresenter : IPresenterBase
{
private IViewBase view;
public MemoryLayoutPresenter(IViewBase myView)
{
this.view = myView;
}
}
public class Program {
public static void Main() {
InjectionContainer.Create<typeof(MemoryLayoutPresenter)>();
}
}