public void UpdateInvalid() { Request entity = CreateEntity(); Guid entityGuid = GetId(entity); var mock = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict); mock.Setup(m => m.Get(entityGuid)).Throws(new ExceptionController()); var controller = new RequestLogic(mock.Object); Assert.ThrowsException <ExceptionController>(() => controller.Update(entity)); mock.VerifyAll(); }
public void UpdateCorrect() { Request entity = CreateEntity(); var mock = new Mock <IRequestRepository <Request, TypeEntity> >(MockBehavior.Strict); mock.Setup(m => m.Get(GetId(entity))).Returns(entity); mock.Setup(m => m.Update(ModifyEntity(entity))); mock.Setup(m => m.Save()); var controller = new RequestLogic(mock.Object); controller.Update(entity); mock.VerifyAll(); }