public void Epic_Service_Add_Method_should_throw_FormatException_with_invalid_input() { //Arrange var request = new EpicMaster(); request.EpicId = 1; var mockRepoReq = new Mock <IEpicRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.Add(request)).Throws(new FormatException()); //mocking GetAll() of RequestRepository EpicService obj = new EpicService(mockRepoReq.Object); //Act var ex = Record.Exception(() => obj.Add(request)); //Assert // Assert.NotNull(res); Assert.IsType <FormatException>(ex); }
public void Epic_Service_Add_Method_should_throw_nullRefrenceException() { //Arrange var request = new EpicMaster(); request.EpicId = 1; var mockRepoReq = new Mock <IEpicRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.Add(request)).Throws(new NullReferenceException()); //mocking GetAll() of RequestRepository EpicService obj = new EpicService(mockRepoReq.Object); //Act var ex = Record.Exception(() => obj.Add(request)); //Assert ; Assert.IsType <NullReferenceException>(ex); }