public void Sprint_service_Update_method_should_throw_nullReferenceException() { var mockRepo = new Mock <ISprintRepository>(); mockRepo.Setup(x => x.Update(It.IsAny <int>(), It.IsAny <UserStory>())).Throws(new NullReferenceException()); SprintService obj = new SprintService(mockRepo.Object); var exception = Record.Exception(() => obj.Update(It.IsAny <int>(), It.IsAny <UserStory>())); Assert.IsType <NullReferenceException>(exception); }
public void Sprint_service_Update_method_should_throw_null_exception_with_empty_input_object() { UserStory bk = new UserStory(); var mockRepo = new Mock <ISprintRepository>(); mockRepo.Setup(x => x.Update(It.IsAny <int>(), bk)); SprintService obj = new SprintService(mockRepo.Object); var exception = Record.Exception(() => obj.Update(It.IsAny <int>(), bk)); Assert.Equal(null, exception); }
public void UpdateTest() { var mock = new Mock <IUnitOfWork>() { DefaultValue = DefaultValue.Mock }; var newSprint = new SprintDTO() { Name = "Name", Description = "Description" }; SprintService service = new SprintService(mock.Object); service.Create(newSprint); newSprint.Name = "NameName"; newSprint.Description = "description"; service.Update(newSprint); var result = service.GetByID(newSprint.Sprint_id); Assert.Equal(result.Sprint_id, newSprint.Sprint_id); Assert.Equal("NameName", result.Name); Assert.Equal("description", result.Description); }