コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }