Пример #1
0
        public void ThrowException_WhenPageContentIsInvalid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <PageContent> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var pageContentService = new PageContentService(mockedRepository.Object, mockedUnitOfWork.Object);

            Mock <PageContent> contentToAdd = null;

            //Act & Assert
            Assert.Throws <NullReferenceException>(() => pageContentService.CreatePageContent(contentToAdd.Object));
        }
Пример #2
0
        public void BeInvokeOnce_WhenParamsAreCorrect()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <PageContent> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var pageContentService = new PageContentService(mockedRepository.Object, mockedUnitOfWork.Object);
            var validContent       = new Mock <PageContent>();

            //Act
            pageContentService.CreatePageContent(validContent.Object);

            //Assert
            mockedRepository.Verify(repository => repository.Add(It.IsAny <PageContent>()), Times.Once);
        }
Пример #3
0
        public void CallSaveChangesOnce_WhenPageContentIsValid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <PageContent> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var pageContentService = new PageContentService(mockedRepository.Object, mockedUnitOfWork.Object);
            var validContent       = new Mock <PageContent>();

            //Act
            pageContentService.CreatePageContent(validContent.Object);

            //Assert
            mockedUnitOfWork.Verify(unit => unit.SaveChanges(), Times.Once);
        }
Пример #4
0
        public void BeInvoked_WhenPageContentIsValid()
        {
            //Arrange
            var mockedRepository   = new Mock <IEFRepository <PageContent> >();
            var mockedUnitOfWork   = new Mock <IUnitOfWork>();
            var pageContentService = new PageContentService(mockedRepository.Object, mockedUnitOfWork.Object);
            var validContent       = new Mock <PageContent>();

            //Act
            pageContentService.CreatePageContent(validContent.Object);

            //Assert
            mockedRepository.Verify(repository => repository.Add(validContent.Object));
        }