public void Get_succeeded_if_username_is_valid() { //arrange var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IUserRepository>(); var admRepo = new Mock <IEmployerRepository>(); repo.Setup(r => r.FindByUserName(It.IsNotNull <string>())) .ReturnsAsync(new User { UserId = Guid.NewGuid() }) .Verifiable(); admRepo.Setup(a => a.FindById(It.Is <Guid>(g => g != Guid.Empty))) .ReturnsAsync(new Employer()) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(admRepo.Object) .Verifiable(); uow.Setup(u => u.UserRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Get("name").Result; //assert repo.Verify(); admRepo.Verify(); uow.Verify(); Assert.NotNull(result); }
public void Get_returns_null_if_username_is_not_valid() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Get(null).Result; //assert Assert.Null(result); }
public void Get_succeeded_if_id_is_valid() { //arrange var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IEmployerRepository>(); repo.Setup(r => r.FindById(It.Is <Guid>(g => g != Guid.Empty))) .ReturnsAsync(new Employer()) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Get(Guid.NewGuid()).Result; //assert repo.Verify(); uow.Verify(); Assert.NotNull(result); }