public void MyTestInitialize() { transaction = new TransactionScope(); userProfile = new UserProfile(); userProfile.loginName = userLoginName; userProfile.enPassword = PasswordEncrypter.Crypt(clearPassword); userProfile.firstName = firstName; userProfile.lastName = lastName; userProfile.email = email; userProfile.language = language; userProfile.country = country; userProfileDao.Create(userProfile); category = new Category(); category.name = categoryName; categoryDao.Create(category); myEvent = new Event(); myEvent.categoryId = categoryId; myEvent.name = name; myEvent.eventDate = date; myEvent.review = review; myEvent.Category = category; myEvent.Comments = new List <Comment>(); myEvent.Recommendations = new List <Recommendation>(); eventDao.Create(myEvent); label = new Label(); label.name = categoryName; labelDao.Create(label); comment = new Comment(); comment.content = content; comment.Event = myEvent; comment.Labels = new List <Label>(); comment.loginName = userProfile.loginName; comment.UserProfile = userProfile; comment.commentDate = DateTime.Now; commentDao.Create(comment); comment2 = new Comment(); comment2.content = content; comment2.Event = myEvent; comment2.Labels = new List <Label>(); comment2.Labels.Add(label); comment2.loginName = userProfile.loginName; comment2.UserProfile = userProfile; comment2.commentDate = date; commentDao.Create(comment2); }
public void DAO_FindByProductIdOrderByDeliveryDateTest() { int numberComments = 3; List <Comment> createdComments = new List <Comment>(numberComments); for (int i = 0; i < numberComments; i++) { var comment = new Comment(); comment.comment1 = commentBody; comment.commentDate = date; comment.productId = product.productId; comment.userId = user.usrId; commentDao.Create(comment); createdComments.Add(comment); } List <Comment> totalRetrievedComments = commentDao.FindByProductIdOrderByDeliveryDate(product.productId); Assert.AreEqual(numberComments, totalRetrievedComments.Count); for (int i = 0; i < numberComments; i++) { Assert.AreEqual(totalRetrievedComments[i], createdComments[i]); } }
public void DAO_FindByTagId() { int numberFoundProducts = 1; List <Product> createdProducts = new List <Product>(); product = new Product(); product.productName = productName + 1; product.productPrice = productPrice; product.productDate = productDate; product.productQuantity = productQuantity; product.Category = category; productDao.Create(product); Comment comment = new Comment(); comment.comment1 = "comment"; comment.commentDate = System.DateTime.Now; comment.productId = product.productId; comment.userId = user.usrId; comment.Tags.Add(tag); commentDao.Create(comment); createdProducts.Add(product); product = new Product(); product.productName = "name" + 2; product.productPrice = productPrice; product.productDate = productDate; product.productQuantity = productQuantity; product.categoryId = category2.categoryId; productDao.Create(product); List <Product> totalRetrievedProducts = productDao.FindByTagId(tag.tagId); Assert.AreEqual(numberFoundProducts, totalRetrievedProducts.Count); for (int i = 0; i < numberFoundProducts; i++) { Assert.AreEqual(totalRetrievedProducts[i], createdProducts[i]); } }