Hi, I am testing this piece of code:
What I would like is to force that exception in some way, right now I have tried this:
public void SaveChanges(){try{//some code here}catch (MyException dbEValEx){RaiseValidationError(dbEValEx);}catch (MySecondException dbUpdateException){RaiseUpdateException(dbUpdateException);}}
What I would like is to force that exception in some way, right now I have tried this:
Any ideas of how to do it?//Class to be testedvar fooUnitOfWork = Mock.Create<UnitOfWork>(Behavior.CallOriginal);//Mock private methodMock.NonPublic.Arrange(fooUnitOfWork, "RaiseValidationError", dbEntityValidationException).DoNothing().MustBeCalled();//Execute method to testfooUnitOfWork.SaveChanges();Mock.Arrange(() => fooUnitOfWork.SaveChanges()).Throws(new DbEntityValidationException());//Make sure that the RaiseDBValidationError is calledMock.Assert(fooUnitOfWork);
