Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }