Beispiel #1
0
 public void TestCatsCollectionSignalsWhenCatIsAdded()
 {
     CatOwner anOwner = new CatOwner("Drake");
     Mock<ICat> mockCat = new Mock<ICat>();
     bool fired = false;
     NotifyCollectionChangedEventHandler handler = (a, b) => { fired = true; };
     anOwner.CatsNotifyCollectionChanged.CollectionChanged += handler;
     anOwner.AddCat(mockCat.Object);
     Assert.IsTrue(fired);
 }
 public void TestCatOwnerMapping()
 {
     ICatOwner aCatOwner = new CatOwner("Bill");
     Mock<ICat> mockCat = new Mock<ICat>();
     aCatOwner.AddCat(mockCat.Object);
     AutoMapperDTOMapper mapper = new AutoMapperDTOMapper();
     CatOwnerDataContract dto = mapper.Map<ICatOwner, CatOwnerDataContract>(aCatOwner);
     Assert.AreEqual(aCatOwner.Name, dto.Name);
     Assert.AreEqual(mockCat.Object, dto.Cats[0]);
     ICatOwner aCatOwner2 = mapper.Map<CatOwnerDataContract, ICatOwner>(dto);
     Assert.AreEqual(aCatOwner, aCatOwner2);
 }