Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 30th, 2012  |  syntax: None  |  size: 1.14 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Does it make a sense to write a unit test to check does it implement an interface?
  2. public class ComparableCustomType: IComparable
  3.     {
  4.         private readonly someFields;
  5.  
  6.         public ComparableCustomType(AnotherBusinessObject obj)
  7.         {
  8.               //Do some parsing against the obj
  9.         }
  10.  
  11.         public int CompareTo(object obj)
  12.         {
  13.              //Some custom sorting logic
  14.         }
  15.     }
  16.        
  17. [TestMethod]
  18. public void CompareTo_IsImplementIComaparable()
  19. {
  20.       IComparable comparable = Isolate.Fake.Instance<ComparableCustomType>();
  21.       Assert.AreNotEqual(null, comparable);    
  22. }
  23.        
  24. public class CustomItem{
  25.  
  26.     private AnotherBusinessObject anotherBusinessObj = null
  27.  
  28.     public CustomItem(AnotherBusinessObject obj)
  29.     {
  30.         this.anotherBusinessObj = obj;
  31.     }
  32.  
  33.     public ComparableCustomType {
  34.         get { return new CamparableCustomType(this.anotherBusinessObj); }
  35.     }
  36.  
  37.     public string SomeOtherProperty {get;set;}
  38.  
  39.     publci int AnotherProperty {get;set;}
  40.  
  41. }
  42.  
  43. public ObservableCollection<CustomItem> MyCustomCollection {get;set;}
  44.        
  45. IComparable foo = new FooComparable();
  46.        
  47. IComparable dataSource = fooObj;