public void CitationService_Get_ByPage_Overload_Calls_Repository_Get()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int treeId = TestConstants.TREE_Id;

            //Act
            _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount);

            //Assert
            mockRepository.Verify(r => r.Get(It.IsAny<int>()));
        }
        public void CitationService_Get_ByPage_Overload_Returns_PagedList_Of_Citations()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetCitations(TestConstants.PAGE_TotalCount));
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int treeId = TestConstants.TREE_Id;

            //Act
            var citations = _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount);

            //Assert
            Assert.IsInstanceOf<IPagedList<Citation>>(citations);
            Assert.AreEqual(TestConstants.PAGE_TotalCount, citations.TotalCount);
            Assert.AreEqual(TestConstants.PAGE_RecordCount, citations.PageSize);
        }
        public void CitationService_Get_ByPage_Overload_Throws_On_Negative_TreeId()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, t => true, 0, TestConstants.PAGE_RecordCount));
        }
        public void CitationService_Get_Overload_Throws_On_Negative_TreeId()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1));
        }
        public void CitationService_Get_Returns_Null_On_InValid_Id()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetCitations(TestConstants.PAGE_TotalCount));
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int id = TestConstants.ID_NotFound;

            //Act
            var citation = _service.Get(id, It.IsAny<int>());

            //Assert
            Assert.IsNull(citation);
        }
        public void CitationService_Get_Calls_Repository_Get()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Citation>>();
            _mockUnitOfWork.Setup(u => u.GetRepository<Citation>()).Returns(mockRepository.Object);

            _service = new CitationService(_mockUnitOfWork.Object);
            const int id = TestConstants.ID_Exists;

            //Act
            _service.Get(id, It.IsAny<int>());

            //Assert
            mockRepository.Verify(r => r.Get(It.IsAny<int>()));
        }
        public void CitationService_Get_Throws_On_Negative_Id()
        {
            //Arrange
            _service = new CitationService(_mockUnitOfWork.Object);

            //Assert
            Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, It.IsAny<int>()));
        }