Should I be testing this class?
I know this could be a very simple question, but I have a little bit of mind at this point. Should I be unit testing this class.
public class MapinfoWindowHandle : IWin32Window
{
IntPtr handle;
public MapinfoWindowHandle(IntPtr mapinfoHandle)
{
this.handle = mapinfoHandle;
}
#region IWin32Window Members
IntPtr IWin32Window.Handle
{
get { return this.handle; }
}
#endregion
}
If I should be what should I be tested over?
I use it like this:
IntPtr handle = new IntPtr(100);
myform.show(new MapinfoWindowHandle(handle));
source to share
The only thing I can see is make sure you pull out the handle that you entered through your constructor. I know it's obvious that you implemented it this way, but the test will convince you that it stays that way. I would check this just because you are injecting it through the constructor. If it was just {get; set; } I probably wouldn't.
[TestMethod]
public void ConstructorTest()
{
IntPtr handle = new IntPtr(100);
MapinfoWindowHandle winHandle = new MapinfoWindowHandle(handle);
Assert.AreEqual( handle, ((IWin32Window)winHandle).Handle );
}
source to share
GUI code is notoriously difficult to unit test. I never found it too useful in my applications. Just keep your business logic outside of your GUI so you can easily test this. I usually test gui code with either manual or automated integration / acceptance tests. It is difficult to write a test to make sure something "looks right".
source to share