
Untitled
By: a guest on
Jul 30th, 2012 | syntax:
None | size: 1.14 KB | hits: 7 | expires: Never
Does it make a sense to write a unit test to check does it implement an interface?
public class ComparableCustomType: IComparable
{
private readonly someFields;
public ComparableCustomType(AnotherBusinessObject obj)
{
//Do some parsing against the obj
}
public int CompareTo(object obj)
{
//Some custom sorting logic
}
}
[TestMethod]
public void CompareTo_IsImplementIComaparable()
{
IComparable comparable = Isolate.Fake.Instance<ComparableCustomType>();
Assert.AreNotEqual(null, comparable);
}
public class CustomItem{
private AnotherBusinessObject anotherBusinessObj = null
public CustomItem(AnotherBusinessObject obj)
{
this.anotherBusinessObj = obj;
}
public ComparableCustomType {
get { return new CamparableCustomType(this.anotherBusinessObj); }
}
public string SomeOtherProperty {get;set;}
publci int AnotherProperty {get;set;}
}
public ObservableCollection<CustomItem> MyCustomCollection {get;set;}
IComparable foo = new FooComparable();
IComparable dataSource = fooObj;