コード例 #1
0
        public void CitationService_Update_Calls_Repository_Update_Method_With_The_Same_Citation_Object_It_Recieved()
        {
            // Create test data
            var citation = new Citation
                                {
                                    Id = TestConstants.ID_Exists,
                                    Text = "Foo",
                                    Page = "Bar"
                                };

            //Create Mock
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object);

            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Act
            _service.Update(citation);

            //Assert
            mockRepository.Verify(r => r.Update(citation));
        }
コード例 #2
0
        public void CitationService_Update_Calls_UnitOfWork_Commit_Method()
        {
            // Create test data
            var citation = new Citation
                                {
                                    Id = TestConstants.ID_Exists,
                                    Text = "Foo",
                                    Page = "Bar"
                                };

            //Create Mock
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(d => d.GetRepository<Citation>()).Returns(mockRepository.Object);

            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Act
            _service.Update(citation);

            //Assert
            _mockUnitOfWork.Verify(db => db.Commit());
        }
コード例 #3
0
        public void CitationService_Update_Throws_On_Null_Citation()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<ArgumentNullException>(() => _service.Update(null));
        }