public void DeleteEmployer_failed_if_name_is_null() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Delete((String)null).Result; //assert Assert.False(result.Succeeded); }
public void DeleteEmployer_failed_if_id_is_not_valid() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Delete(Guid.Empty).Result; //assert Assert.False(result.Succeeded); }
public void DeleteEmployer_succeeded_if_name_is_valid() { //arrange var EmployerToDelete = new Employer { User = new User() }; var Employers = new List <Employer> { EmployerToDelete }; var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IEmployerRepository>(); var usrRepo = new Mock <IUserRepository>(); usrRepo.Setup(u => u.Remove(It.IsNotNull <User>())) .Callback <User>(a => Employers.Remove(EmployerToDelete)) .Verifiable(); usrRepo.Setup(u => u.FindByUserName(It.IsNotNull <string>())) .ReturnsAsync(new User { UserId = Guid.NewGuid() }) .Verifiable(); repo.Setup(r => r.FindById(It.Is <Guid>(g => g != Guid.Empty))) .ReturnsAsync(EmployerToDelete) .Verifiable(); uow.Setup(u => u.SaveChanges()) .ReturnsAsync(1) .Verifiable(); uow.Setup(u => u.UserRepository) .Returns(usrRepo.Object) .Verifiable(); uow.Setup(u => u.EmployerRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Delete("asdasd").Result; //assert usrRepo.Verify(); repo.Verify(); uow.Verify(); Assert.True(result.Succeeded); Assert.Equal(0, Employers.Count); }