public void CreateEmployer_succeeded_if_Employer_is_valid() { //arrange var Employers = new List <Employer>(); var uow = new Mock <IUnitOfWork>(); var repo = new Mock <IUserRepository>(); repo.Setup(r => r.AddEmployer(It.IsNotNull <Employer>())) .Callback <Employer>(a => Employers.Add(a)) .Verifiable(); uow.Setup(u => u.SaveChanges()) .ReturnsAsync(1) .Verifiable(); uow.Setup(u => u.UserRepository) .Returns(repo.Object) .Verifiable(); var manager = new EmployerManager(uow.Object); //act var result = manager.Create(new Employer()).Result; //assert repo.Verify(); uow.Verify(); Assert.True(result.Succeeded); Assert.Equal(1, Employers.Count); }
public void CreateEmployer_failed_if_Employer_is_not_valid() { //arrange var uow = Mock.Of <IUnitOfWork>(); var manager = new EmployerManager(uow); //act var result = manager.Create(null).Result; //assert Assert.False(result.Succeeded); }