public void GetAllCommentsForListing_ReturnsACommentListOfLengthZero_WhenListingIdIsPassedAndDatabaseIsEmpty() { // Arrange int expected = 0; int Id = 1; SqlServerCommentRepository commentRepo = new SqlServerCommentRepository(context); // Act int actual = commentRepo.GetAllCommentsForListing(Id).Count(); // Assert Assert.AreEqual(expected, actual); }
public void AddComment_AddsCommentToDatabaseAndReturnsACommentOfIdValueOne_WhenCalledWithCommentObjectOfIdValueOne() { // Arrange int expected = 1; Shipping shipping = new Shipping() { Id = 1, ShipMode = "mode" }; ProductCategory category = new ProductCategory() { Id = 1, ProductCategoryName = "name" }; Status status = new Status() { Id = 1, StatusName = "name" }; User user = new User() { Id = 1, EmailAddress = "*****@*****.**", Password = "******", Username = "******", Address = "address" }; Listing listing = new Listing(); listing.Id = 1; listing.ItemName = "name"; listing.Quantity = 1; listing.AuctionStartTime = DateTime.Now.Date; listing.AuctionEndTime = DateTime.Now.Date; listing.Price = 0; listing.Description = "descr"; listing.ImageUrl = "/image"; listing.Shipping = shipping; listing.ProductCategory = category; listing.Status = status; listing.User = user; Comment comment = new Comment() { Id = 1, Content = "comment", Listing = listing, User = user }; SqlServerCommentRepository commentRepo = new SqlServerCommentRepository(context); // Act commentRepo.AddComment(comment); int actual = context.Comments.Count(); // Assert Assert.AreEqual(expected, actual); }