I've just got started on TDD and very quickly ran into a brick wall. Here's my scenario... I'm trying to model an Image object, and going through the TDD steps I've started with a simple object which eventual grew into...
public class ImageObject
{
public string Name {get; set;}
public int Width {get; set;}
public int Height {get; set;}
public bool IsValid()
{
//Some rules
}
}
Of course the obligatory tests...
[Test]
public void ImageWidthCannotBeLessThanZero {...}
[Test]
public void ImageHeightCannotBeLessThanZero {...}
and so forth...
So far so good. Next, I want to represent the physical file in the class somehow. It could be with a file path
public class ImageObject
{
public string Path {get; set;}
}
or a series of bytes
public class ImageObject
{
public byte[] Bytes {get; set;}
}
(Please this is not an argument about DB vs File system for storage.)
At this point I'm not feeling comfortable because my mind is drifting and starting thinking about the infrastructure/implementation details. Where is my flaw?? Should i make the decision upfront on the implementation detail? Do i need a clever design pattern to deal with this? Would a mocking framework help? This is an Object Analysis/Design problem and I should use UML tools? (Wait a minute i thought TDD was about design?)
Anyway how do i overcome this of problem? I want to remain focused on designing my objects and not think about infrastructure concerns at this time?