public void WhenGettingEntity_ThenReturnsCorrectEntity() { // Arrange var repositoryMock = new Mock<IPortalRepository>(); Portal newEntity = DefaultModelHelper.DummyPopulatedPortal(); repositoryMock.Setup(repo => repo.GetById(It.IsAny<int>())).Returns(newEntity); // Act var services = new PortalService(repositoryMock.Object, new Mock<IUnitOfWork>().Object); Portal returnedEntity = services.GetById(1); // Assert Assert.NotNull(returnedEntity); Assert.Equal("Title", returnedEntity.Title); }