Exemple #1
0
        public void TestMethod_ListWishes()
        {
            TestMethod_CreateWish();

            WishRepository      _wishRepository     = new WishRepository();
            WishService         wishService         = new WishService(_wishRepository);
            PaginationParameter paginationParameter = new PaginationParameter();

            Assert.IsNotNull(wishService.ListWishesAsync(paginationParameter, 1));
            Assert.AreEqual(wishService.ListWishesAsync(paginationParameter, 2).Result.Count, 0);
        }
Exemple #2
0
        public void TestMethod_DeleteWish()
        {
            TestMethod_CreateWish();

            WishRepository _wishRepository = new WishRepository();
            WishService    wishService     = new WishService(_wishRepository);

            Assert.AreEqual(wishService.RemoveWishAsync(1, 1).Result, true);
            Assert.AreEqual(wishService.RemoveWishAsync(1, 2).Result, false);
            Assert.AreEqual(wishService.RemoveWishAsync(1, 3).Result, true);
        }
Exemple #3
0
        public void TestMethod_CreateWish_Sem_User()
        {
            ProductRepository _productRepository = new ProductRepository();
            ProductService    productService     = new ProductService(_productRepository);

            Assert.AreEqual(productService.CreateProductAsync("Batedeira").Result, true);

            WishRepository _wishRepository = new WishRepository();
            WishService    wishService     = new WishService(_wishRepository);

            Assert.AreEqual(wishService.CreateWishAsync(1, 1).Result, false);
        }
Exemple #4
0
        public void TestMethod_CreateWish_Sem_Produto()
        {
            UserRepository _userRepository = new UserRepository();
            UserService    userService     = new UserService(_userRepository);

            Assert.AreEqual(userService.CreateUserAsync("Rodrigo Carvalho", "*****@*****.**").Result, true);

            WishRepository _wishRepository = new WishRepository();
            WishService    wishService     = new WishService(_wishRepository);

            Assert.AreEqual(wishService.CreateWishAsync(1, 1).Result, false);
        }
        public IActionResult Atualizar(Wish newWish)
        {
            Wish oldWish = WishRepository.BuscarWishPorId(newWish.WishId);

            if (oldWish == null)
            {
                return(NotFound());
            }

            WishRepository.Atualizar(newWish, oldWish);

            return(Ok());
        }
 public IActionResult ListarTodos()
 {
     try
     {
         return(Ok(WishRepository.ListarTodos()));
     }
     catch (Exception ex)
     {
         return(BadRequest(new
         {
             mensagem = "Erro: " + ex
         }));
     }
 }
Exemple #7
0
        public void TestMethod_CreateWish()
        {
            ProductRepository _productRepository = new ProductRepository();
            ProductService    productService     = new ProductService(_productRepository);

            Assert.AreEqual(productService.CreateProductAsync("Batedeira").Result, true);
            Assert.AreEqual(productService.CreateProductAsync("Video Cassete").Result, true);
            Assert.AreEqual(productService.CreateProductAsync("Toca Fitas").Result, true);

            UserRepository _userRepository = new UserRepository();
            UserService    userService     = new UserService(_userRepository);

            Assert.AreEqual(userService.CreateUserAsync("Rodrigo Carvalho", "*****@*****.**").Result, true);

            WishRepository _wishRepository = new WishRepository();
            WishService    wishService     = new WishService(_wishRepository);

            Assert.AreEqual(wishService.CreateWishAsync(1, 1).Result, true);
            Assert.AreEqual(wishService.CreateWishAsync(1, 3).Result, true);
        }
        public IActionResult ListarPorLogado()
        {
            try
            {
                int userId = Convert.ToInt32(HttpContext.User.Claims.First(c => c.Type == JwtRegisteredClaimNames.Jti).Value);

                Users usuarioProcurado = UserRepository.BuscarPorId(userId);

                if (usuarioProcurado == null)
                {
                    return(NotFound());
                }
                return(Ok(WishRepository.ListarPorUser(userId)));
            }
            catch (Exception ex)
            {
                return(BadRequest(new
                {
                    mensagem = "Erro: " + ex
                }));
            }
        }
 public WishesController()
 {
     WishRepository = new WishRepository();
     UserRepository = new UserRepository();
 }
Exemple #10
0
 public WishService(WishRepository repo)
 {
     _repo = repo;
 }