public void Backlog_serive_update_method_throw_Format_Exception_with_invalid_input() { UserStory backlog = new UserStory(); backlog.StoryId = 1; var mockrepo = new Mock <IBacklogRepository>(); mockrepo.Setup(x => x.Update(It.IsAny <int>(), backlog)).Throws(new FormatException()); BacklogService obj = new BacklogService(mockrepo.Object); var exception = Record.Exception(() => obj.Update(It.IsAny <int>(), backlog)); Assert.IsType <FormatException>(exception); }
public void Backlog_serive_update_method_throw_nullrefrence_Exception() { UserStory backlog = new UserStory(); backlog.StoryId = 1; var mockrepo = new Mock <IBacklogRepository>(); mockrepo.Setup(x => x.Update(It.IsAny <int>(), backlog)).Throws(new NullReferenceException()); BacklogService obj = new BacklogService(mockrepo.Object); var exception = Record.Exception(() => obj.Update(It.IsAny <int>(), backlog)); Assert.IsType <NullReferenceException>(exception); }
public void Backlog_Service_Update_Method_should_return_ProductBacklog_Type_object() { //Arrange List <UserStory> requests = new List <UserStory>(); var request = new UserStory(); request.StoryId = 1; requests.Add(request); var mockRepoReq = new Mock <IBacklogRepository>(); //mocking RequestRepository mockRepoReq.Setup(x => x.Update(It.IsAny <int>(), request)).Returns(request); //mocking GetAll() of RequestRepository BacklogService obj = new BacklogService(mockRepoReq.Object); //Act var res = obj.Update(It.IsAny <int>(), request); //Assert Assert.IsType <UserStory>(res); }