public void MultimediaLinkService_Get_ByPage_Overload_Returns_PagedList_Of_MultimediaLinks() { //Arrange var mockRepository = new Mock<IRepository<MultimediaLink>>(); mockRepository.Setup(r => r.Get(It.IsAny<int>())).Returns(GetMultimediaLinks(TestConstants.PAGE_TotalCount)); _mockUnitOfWork.Setup(u => u.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); _service = new MultimediaLinkService(_mockUnitOfWork.Object); const int treeId = TestConstants.TREE_Id; //Act var multimediaLinks = _service.Get(treeId, t => true, 0, TestConstants.PAGE_RecordCount); //Assert Assert.IsInstanceOf<IPagedList<MultimediaLink>>(multimediaLinks); Assert.AreEqual(TestConstants.PAGE_TotalCount, multimediaLinks.TotalCount); Assert.AreEqual(TestConstants.PAGE_RecordCount, multimediaLinks.PageSize); }
public void MultimediaLinkService_Get_ByPage_Overload_Throws_On_Negative_TreeId() { //Arrange _service = new MultimediaLinkService(_mockUnitOfWork.Object); //Assert Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1, t => true, 0, TestConstants.PAGE_RecordCount)); }
public void MultimediaLinkService_Get_ByPage_Overload_Calls_Repository_Get() { //Arrange var mockRepository = new Mock<IRepository<MultimediaLink>>(); _mockUnitOfWork.Setup(u => u.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); _service = new MultimediaLinkService(_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 MultimediaLinkService_Get_Overload_Calls_Repository_Get() { //Arrange var mockUnitOfWork = new Mock<IUnitOfWork>(); var mockRepository = new Mock<IRepository<MultimediaLink>>(); mockUnitOfWork.Setup(d => d.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); _service = new MultimediaLinkService(mockUnitOfWork.Object); const int treeId = TestConstants.TREE_Id; //Act _service.Get(treeId); //Assert mockRepository.Verify(r => r.Get(treeId)); }
public void MultimediaLinkService_Get_Overload_Throws_On_Negative_TreeId() { //Arrange var mockUnitOfWork = new Mock<IUnitOfWork>(); _service = new MultimediaLinkService(mockUnitOfWork.Object); //Assert Assert.Throws<IndexOutOfRangeException>(() => _service.Get(-1)); }
public void MultimediaLinkService_Get_Returns_Null_On_InValid_Id() { //Arrange _mockUnitOfWork = new Mock<IUnitOfWork>(); var mockRepository = new Mock<IRepository<MultimediaLink>>(); mockRepository.Setup(r => r.GetAll()).Returns(GetMultimediaLinks(TestConstants.PAGE_TotalCount)); _mockUnitOfWork.Setup(d => d.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); _service = new MultimediaLinkService(_mockUnitOfWork.Object); const int id = TestConstants.ID_NotFound; //Act var multimediaLink = _service.Get(id, TestConstants.TREE_Id); //Assert Assert.IsNull(multimediaLink); }
public void MultimediaLinkService_Get_Calls_Repository_GetAll() { //Arrange _mockUnitOfWork = new Mock<IUnitOfWork>(); var mockRepository = new Mock<IRepository<MultimediaLink>>(); _mockUnitOfWork.Setup(d => d.GetRepository<MultimediaLink>()).Returns(mockRepository.Object); _service = new MultimediaLinkService(_mockUnitOfWork.Object); const int id = TestConstants.ID_Exists; //Act _service.Get(id, TestConstants.TREE_Id); //Assert mockRepository.Verify(r => r.Get(TestConstants.TREE_Id)); }
public void MultimediaLinkService_Get_Throws_On_Negative_TreeId() { //Arrange _mockUnitOfWork = new Mock<IUnitOfWork>(); _service = new MultimediaLinkService(_mockUnitOfWork.Object); //Assert Assert.Throws<IndexOutOfRangeException>(() => _service.Get(It.IsAny<int>(), -1)); }