public void TestAddProductAuctionSameUser() { AuctionService auctionService = new AuctionService(); ProductService productService = new ProductService(); CurrencyService currencyService = new CurrencyService(); UserService userService = new UserService(); ProductAuctionService productAuctionService = new ProductAuctionService(); RoleService roleService = new RoleService(); Auction auction = auctionService.GetAuctionById(1); Role role = roleService.GetRoleByName("actioneer"); userService.AddRoleToUser("[email protected]", role); User user = userService.GetUserById(1); Product product = productService.GetProductById(1); Double price = 100; Currency currency = currencyService.getCurrencyById(1); try { productAuctionService.AddProductAuction(user, product, price, currency); } catch (ValidationException exc) { Assert.AreEqual("The ownwer and the actioneer cannot be the same user", exc.Message); } }
public void TestAddProductNullCurrency() { AuctionService auctionService = new AuctionService(); ProductService productService = new ProductService(); CurrencyService currencyService = new CurrencyService(); UserService userService = new UserService(); ProductAuctionService productAuctionService = new ProductAuctionService(); RoleService roleService = new RoleService(); Product product = productService.GetProductById(1); Double price = 200; Currency currency = currencyService.getCurrencyById(1); Role role = roleService.GetRoleByName("owner"); userService.AddRoleToUser("*****@*****.**", role); User user = userService.GetUserById(2); try { productAuctionService.AddProductAuction(user, product, price, null); } catch (EntityDoesNotExistException exc) { Assert.AreEqual("Currency is null", exc.Message); } }
public void TestAddProductAuctionOwner() { AuctionService auctionService = new AuctionService(); ProductService productService = new ProductService(); CurrencyService currencyService = new CurrencyService(); UserService userService = new UserService(); ProductAuctionService productAuctionService = new ProductAuctionService(); RoleService roleService = new RoleService(); Product product = productService.GetProductById(1); Double price = 2000; Currency currency = currencyService.getCurrencyById(1); Role role = roleService.GetRoleByName("owner"); userService.AddRoleToUser("*****@*****.**", role); User user = userService.GetUserById(3); try { productAuctionService.AddProductAuction(user, product, price, currency); } catch (ValidationException exc) { Assert.AreEqual("The user is not actioneer", exc.Message); } }