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

            _service = new FactService(_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 FactService_Get_ByPage_Overload_Returns_PagedList_Of_Facts()
        {
            //Arrange
            var mockRepository = new Mock<IRepository<Fact>>();
            mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetFacts(TestConstants.PAGE_TotalCount));
            _mockUnitOfWork.Setup(u => u.GetRepository<Fact>()).Returns(mockRepository.Object);

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

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

            //Assert
            Assert.IsInstanceOf<IPagedList<Fact>>(facts);
            Assert.AreEqual(TestConstants.PAGE_TotalCount, facts.TotalCount);
            Assert.AreEqual(TestConstants.PAGE_RecordCount, facts.PageSize);
        }
        public void FactService_Get_ByPage_Overload_Throws_On_Negative_TreeId()
        {
            //Arrange
            _service = new FactService(_mockUnitOfWork.Object);

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

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

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

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

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

            _service = new FactService(_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 FactService_Get_Throws_On_Negative_Id()
        {
            //Arrange
            _service = new FactService(_mockUnitOfWork.Object);

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