제목을 붙입니다.유닛 테스트를 작성하여 인터페이스를 구현하는지 확인하는 것이 의미가 있습니까?
나는 정렬이 필요한 IComparable을 구현하는 클래스가 있습니다. 모든 방법에 대해 모든 단위 테스트를 작성했습니다. 하지만 IComparable을 구현하는지 확인하기 위해 단위 테스트를 작성하는 것이 합리적입니까?
UI로 정렬 할 때 인터페이스가 작동하지 않기 때문에. 그러나 컴파일은 여전히 작동 할 것입니다. 그래서 만약 내가 그러한 테스트 케이스를 가지고 있다면, 누군가 그 인터페이스를 제거했는지 알 수 있습니다. .... 나는이 속성을 사용하는 방법이 (또는 그게 말할해야
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;}
그러면이 컬렉션은 내 GridView ....에 데이터 바인딩됩니다. 그러면 automa가됩니다. tically 모든 열을 생성 .....
이제 응용 프로그램에서 객체를 인스턴스화하고 사용하는 방법은 무엇입니까? 그게 제가 주로 궁금해 한 것입니다. – jlafay
@jlafay이 컬렉션 항목의 속성으로 사용됩니다. 간단한 코드를 넣어 보겠습니다 ... –