public void DAO_FindTest() { try { UserProfile actual = userProfileDao.Find(userProfile.usrId); Assert.AreEqual(userProfile, actual, "User found does not correspond with the original one."); } catch (Exception e) { Assert.Fail(e.Message); } }
public void AddCardTest() { using (TransactionScope scope = new TransactionScope()) { // Register user and find profile long userId = userService.RegisterUser(loginName, clearPassword, new UserProfileDetails(firstName, lastName, email, language, country, address)); UserProfile userProfile = userProfileDao.Find(userId); // Add a card and find string cardNumber = "11111"; int verficationCode = 222; DateTime expirationDate = DateTime.Now; string type = "Credit"; CardDetails cardDetails = new CardDetails(cardNumber, verficationCode, expirationDate, type); cardService.AddCard(userId, cardDetails); Card card = cardDao.FindByCardNumber(cardNumber); // Check data Assert.AreEqual(cardNumber, card.cardNumber); Assert.AreEqual(userId, card.usrId); Assert.AreEqual(verficationCode, card.verificationCode); Assert.AreEqual(expirationDate, card.expirationDate); Assert.AreEqual(type, card.cardType); Assert.AreEqual(true, card.defaultCard); cardNumber = "22222"; verficationCode = 333; expirationDate = DateTime.Now; type = "Debit"; CardDetails cardDetails2 = new CardDetails(cardNumber, verficationCode, expirationDate, type); cardService.AddCard(userId, cardDetails2); Card card2 = cardDao.FindByCardNumber(cardNumber); // Check data Assert.AreEqual(cardNumber, card2.cardNumber); Assert.AreEqual(userId, card2.usrId); Assert.AreEqual(verficationCode, card2.verificationCode); Assert.AreEqual(expirationDate, card2.expirationDate); Assert.AreEqual(type, card2.cardType); Assert.AreEqual(false, card2.defaultCard); userProfileDao.Remove(userId); //transaction.Complete() is not called, so Rollback is executed. } }
public void GenerateOrderTest() { using (TransactionScope scope = new TransactionScope()) { // Create a category long categoryId = CreateCategory("Music"); // Create a product long productId = CreateProduct(categoryId, "Dire Straits", 10, (float)8.65); long product2Id = CreateProduct(categoryId, "ACDC", 10, (float)8.65); // Register User UserProfileDetails user = new UserProfileDetails("pepito", "delospalotes", "*****@*****.**", "es", "ES", 12345); long usrId = userService.RegisterUser("pepito07", "abcbd1234", user); // Get Products List <ProductDetails> shoppingCart = new List <ProductDetails>(); ProductDetails p1 = productService.FindProduct(productId); p1.numberOfUnits = 1; ProductDetails p2 = productService.FindProduct(product2Id); shoppingCart.Add(p1); shoppingCart.Add(p2); // Add card CardDetails card = new CardDetails("123456789", 123, DateTime.Now, "Credit"); cardService.AddCard(usrId, card); long cardId = userDao.Find(usrId).Cards.ElementAt(0).idCard; // Generate order long orderId = orderService.GenerateOrder(usrId, cardId, 12345, shoppingCart); Order order = orderDao.Find(orderId); Assert.AreEqual(orderId, order.orderId); Assert.AreEqual(order.usrId, usrId); Assert.AreEqual(cardId, order.idCard); Assert.AreEqual(12345, order.postalAddress); Assert.AreEqual(shoppingCart.Count, order.OrderLines.Count); Assert.AreEqual(shoppingCart[0].productId, order.OrderLines.ElementAt(0).productId); Assert.AreEqual(shoppingCart[1].productId, order.OrderLines.ElementAt(1).productId); } }
public void RegisterUserTest() { using (TransactionScope scope = new TransactionScope()) { // Register user and find profile long userId = userService.RegisterUser(loginName, clearPassword, new UserProfileDetails(firstName, lastName, email, language, country)); UserProfile userProfile = userProfileDao.Find(userId); // Check data Assert.AreEqual(userId, userProfile.usrId); Assert.AreEqual(loginName, userProfile.loginName); Assert.AreEqual(PasswordEncrypter.Crypt(clearPassword), userProfile.enPassword); Assert.AreEqual(firstName, userProfile.firstName); Assert.AreEqual(lastName, userProfile.lastName); Assert.AreEqual(email, userProfile.email); Assert.AreEqual(language, userProfile.language); Assert.AreEqual(country, userProfile.country); // transaction.Complete() is not called, so Rollback is executed. } }
public void RegisterUserTest() { // Register user and find profile long userId = userService.RegisterUser(loginName, clearPassword, new UserProfileDetails(firstName, lastName, email, language, country)); UserProfile userProfile = userProfileDao.Find(userId); // Check data Assert.AreEqual(userId, userProfile.usrId); Assert.AreEqual(loginName, userProfile.loginName); Assert.AreEqual(PasswordEncrypter.Crypt(clearPassword), userProfile.enPassword); Assert.AreEqual(firstName, userProfile.firstName); Assert.AreEqual(lastName, userProfile.lastName); Assert.AreEqual(email, userProfile.email); Assert.AreEqual(language, userProfile.language); Assert.AreEqual(country, userProfile.country); }
public void RegisterUserTest() { using (var scope = new TransactionScope()) { // Register user and find profile var userId = userService.RegisterUser(loginName, clearPassword, new UserProfileDetails(firstName, lastName, email, language, country, role, address)); var userProfile = userProfileDao.Find(userId); // Check data Assert.AreEqual(userId, userProfile.usrId); Assert.AreEqual(loginName, userProfile.loginName); Assert.AreEqual(PasswordEncrypter.Crypt(clearPassword), userProfile.enPassword); Assert.AreEqual(firstName, userProfile.firstName); Assert.AreEqual(lastName, userProfile.lastName); Assert.AreEqual(email, userProfile.email); Assert.AreEqual(language, userProfile.language); Assert.AreEqual(country, userProfile.country); Assert.AreEqual(role, userProfile.role); Assert.AreEqual(address, userProfile.address); } }