Exemplo n.º 1
0
        public async Task GetDepartamentsSuccess()
        {
            //Arrange
            var departaments = new List <Departament>
            {
                new Departament {
                    Name = "test", Id = 1
                },
                new Departament {
                    Name = "test", Id = 2
                }
            };

            var getDepartaments = new List <GetDepartamentDto>
            {
                new GetDepartamentDto {
                    Name = "test"
                },
                new GetDepartamentDto {
                    Name = "test"
                }
            };

            unitOfWork.Setup(x => x.Repository <Departament>().GetAll()).Returns(Task.FromResult(departaments));

            unitOfWork.Setup(x => x.Mapper().Map <List <GetDepartamentDto> >(departaments)).Returns(getDepartaments);

            var service = new DepartamentService(unitOfWork.Object);

            //Act
            var action = await service.GetDepartaments();

            //Arrange
            Assert.Equal(2, action.Count);
        }
Exemplo n.º 2
0
        public async Task AddDepartamentFailed()
        {
            //Arrange
            var createDepartament = new CreateDepartamentDto {
                Name = "test"
            };
            var departament = new Departament {
                Name = "test"
            };

            unitOfWork.Setup(x => x.Mapper().Map <Departament>(createDepartament)).Returns(departament);

            unitOfWork.Setup(x => x.Repository <Departament>().Add(departament)).Verifiable();

            unitOfWork.Setup(x => x.SaveAllAsync()).Returns(Task.FromResult(false));

            var service = new DepartamentService(unitOfWork.Object);

            //Act
            var action = await service.AddDepartament(createDepartament);

            //Assert
            Assert.False(action);
            unitOfWork.Verify(x => x.Repository <Departament>().Add(departament), Times.Once);
        }
 public SellersController(SellerService sellerService, DepartamentService departamentService)
 {
     _sellerService      = sellerService;
     _departamentService = departamentService;
 }
Exemplo n.º 4
0
 public SellersController(SellerServices sel, DepartamentService depservice)
 {
     _sel        = sel;
     _depservice = depservice;
 }
 public VendedoresController(ProjetoWebContext context, DepartamentService dps)
 {
     _context   = context;
     _dpservice = dps;
 }
Exemplo n.º 6
0
 public DepartamentsController(DepartamentService departamentService)
 {
     _departamentService = departamentService;
 }
Exemplo n.º 7
0
 public VendedorController(SellerService sellerService, DepartamentService departamentService)
 {
     _sellerService      = sellerService;
     _departamentService = departamentService;
 }
 public SellersController(SellerServices sellersServices, DepartamentService departamentService)
 {
     _sellersServices    = sellersServices;
     _departamentService = departamentService;
 }
Exemplo n.º 9
0
 public SellersController(SellerService sellerService, DepartamentService departamentService)// o contrutor para acessar o servico
 {
     _sellerService      = sellerService;
     _departamentService = departamentService;
 }