public void Backlog_service_Add_method_throw_nullrefrence_Exception() { UserStory backlog = new UserStory(); backlog.StoryId = 1; var mockrepo = new Mock <IBacklogRepository>(); mockrepo.Setup(x => x.Add(backlog)).Throws(new NullReferenceException()); BacklogService obj = new BacklogService(mockrepo.Object); var exception = Record.Exception(() => obj.Add(backlog)); Assert.IsType <NullReferenceException>(exception); }
public void Backlog_serive_Add_method_throw_exception_with_invalid_value_type() { UserStory backlog = new UserStory(); backlog.StoryId = 1; UserStory backlog2 = new UserStory(); backlog.StoryId = 2; var mockrepo = new Mock <IBacklogRepository>(); mockrepo.Setup(x => x.Add(backlog)).Throws(new FormatException()); BacklogService obj = new BacklogService(mockrepo.Object); var exception = Record.Exception(() => obj.Add(backlog)); Assert.IsType <FormatException>(exception); }