public void ThrowArgumentNullExceptionWhenSubmissionIsNull() { // Arrange var mockedRepository = new Mock <IDbRepository <TopicSubmission> >(); var mockedIdentifier = new Mock <IIdentifierProvider>(); var topicSubmissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object); var mockedTopicSubmission = (TopicSubmission)null; // Act & Arrange Assert.Throws <ArgumentNullException>(() => topicSubmissionService.Add(mockedTopicSubmission)); }
public void ThrowArgumentNullExceptionWithMessageThatShouldNotBeBullWhenSubmissionIsNull() { // Arrange var mockedRepository = new Mock <IDbRepository <TopicSubmission> >(); var mockedIdentifier = new Mock <IIdentifierProvider>(); var topicSubmissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object); var mockedTopicSubmission = (TopicSubmission)null; // Act & Arrange var exc = Assert.Throws <ArgumentNullException>(() => topicSubmissionService.Add(mockedTopicSubmission)); StringAssert.Contains("should not be null", exc.Message); }
public void CallSaveMethodOnDbRepositoryOnlyOnce() { // Arrange var mockedRepository = new Mock <IDbRepository <TopicSubmission> >(); var mockedIdentifier = new Mock <IIdentifierProvider>(); var topicSubmissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object); var mockedTopicSubmission = new Mock <TopicSubmission>(); // Act topicSubmissionService.Add(mockedTopicSubmission.Object); // Assert mockedRepository.Verify(m => m.Save(), Times.Once); }