Пример #1
0
        public void ThrowArgumentNullExceptionWhenSubmissionIsNotFound(int invalidId)
        {
            // Arrange
            var mockedRepository  = new Mock <IDbRepository <TopicSubmission> >();
            var mockedIdentifier  = new Mock <IIdentifierProvider>();
            var submissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object);


            // Act & Assert
            Assert.Throws <ArgumentNullException>(() => submissionService.GetById(invalidId));
        }
Пример #2
0
        public void ThrowArgumentNullExceptionWhenSubmissionIsNotFoundWithCorrectMessage(int invalidId)
        {
            // Arrange
            var mockedRepository  = new Mock <IDbRepository <TopicSubmission> >();
            var mockedIdentifier  = new Mock <IIdentifierProvider>();
            var submissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object);

            // Act & Assert
            var exc = Assert.Throws <ArgumentNullException>(() => submissionService.GetById(invalidId));

            StringAssert.Contains("not found", exc.Message);
        }
Пример #3
0
        public void ReturnTopicSubmissionInstance()
        {
            // Arrange
            var mockedRepository  = new Mock <IDbRepository <TopicSubmission> >();
            var mockedIdentifier  = new Mock <IIdentifierProvider>();
            var submissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object);
            var mockedSubmission  = new Mock <TopicSubmission>();

            mockedRepository.Setup(m => m.GetById(1)).Returns(mockedSubmission.Object);
            // Act & Assert

            Assert.IsInstanceOf <TopicSubmission>(submissionService.GetById(1));
        }
Пример #4
0
        public void ThrowArgumentNullExceptionWhenSubmissionIsNull()
        {
            // Arrange
            var mockedRepository  = new Mock <IDbRepository <TopicSubmission> >();
            var mockedIdentifier  = new Mock <IIdentifierProvider>();
            var submissionService = new TopicSubmissionsService(mockedRepository.Object, mockedIdentifier.Object);
            var mockedTopic       = new Mock <TopicSubmission>();

            mockedRepository.Setup(m => m.GetById(1)).Returns((TopicSubmission)null);
            // Act & Assert

            Assert.Throws <ArgumentNullException>(() => submissionService.GetById(1));
            // Assert.IsInstanceOf<Topic>(topicService.GetById(1));
        }