public void Initialize() { //Arrange FakeUnits = new FakeUnits(); //MockRepository MockRepository = new Mock<IGenericRepository<Unit>>(); MockRepository.Setup(x => x.All).Returns(FakeUnits.MyUnits.AsQueryable()); MockRepository.Setup(m => m.Find(It.IsAny<Unit>())).Returns((int d) => FakeUnits.MyUnits.Find(x => x.UnitId == d)); MockRepository.Setup(m => m.Insert(It.IsAny<Unit>())).Callback((Unit unit) => { FakeUnits.MyUnits.Add(unit); }); MockRepository.Setup(m => m.Update(It.IsAny<Unit>())).Callback((Unit unit) => { FakeUnits.MyUnits.Remove(FakeUnits.MyUnits.Find(x => x.UnitId == unit.UnitId)); FakeUnits.MyUnits.Add(unit); }); MockRepository.Setup(m => m.Delete(It.IsAny<Unit>())).Callback((Unit unit) => { FakeUnits.MyUnits.Remove(FakeUnits.MyUnits.Find(x => x.UnitId == unit.UnitId)); }); //MockIUnitofWork MockUnitofWork = new Mock<IGenericUnitofWork>(); MockUnitofWork.SetupGet(x => x.UnitRepository).Returns(MockRepository.Object); }
public void Initialize() { //Arrange var fakeUnits = new FakeUnits(); var unitRepo = new FakeUnitRepository(fakeUnits.MyUnits); var uow = new UnitofWork { UnitRepository = unitRepo }; Controller = new UnitofWorkPatternController(uow); }
public void Initialize() { // Arrange var fakeUnits = new FakeUnits(); var fakeUnitGallery = new FakeUnitGallerys(); var unitRepo = new FakeUnitRepository(fakeUnits.MyUnits); var unitGalleryRepo = new FakeUnitGalleryRepository(fakeUnitGallery.MyUnitGallerys); var uow = new UnitofWork { UnitRepository = unitRepo, UnitGalleryRepository = unitGalleryRepo }; Controller = new PropertyController(uow, null, null); }
public void CleanUp() { MockRepository = null; MockUnitofWork = null; FakeUnits = null; }
public void CleanUp() { FakeUnits = null; Controller = null; }