public void GetAllListings_ReturnsAListingListOfValueZero_WhenCalledAndDatabaseIsEmpty() { // Arrange int expected = 0; SqlServerListingRepository listingRepo = new SqlServerListingRepository(context); // Act int actual = listingRepo.GetAllListings().Count(); // Assert Assert.AreEqual(expected, actual); }
public void GetListingById_ReturnsADefaultListingIdOfValueZero_WhenCalledAndDatabaseIsEmpty() { // Arrange int expected = 0; int id = 1; SqlServerListingRepository listingRepo = new SqlServerListingRepository(context); // Act int actual = listingRepo.GetListingById(id).Id; // Assert Assert.AreEqual(expected, actual); }
public void GetAllListings_ReturnsAListingListOfLengthOne_WhenCalledAndDatabaseHasOneListing() { // Arrange int expected = 1; InsertData(); SqlServerListingRepository listingRepo = new SqlServerListingRepository(context); // Act int actual = listingRepo.GetAllListings().Count(); // Assert Assert.AreEqual(expected, actual); }
public void GetListingById_ReturnsAListingIdOfValueOne_WhenCalledAndDatabaseHasOneListingOfIdOne() { // Arrange int expected = 1; int id = 1; InsertData(); SqlServerListingRepository listingRepo = new SqlServerListingRepository(context); // Act int actual = listingRepo.GetListingById(id).Id; // Assert Assert.AreEqual(expected, actual); }
public void AddListing_AddsListingToDatabaseAndReturnsListingOfIdValueOne_WhenCalledWithListingObjectOfIdValueOne() { // 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; SqlServerListingRepository listingRepo = new SqlServerListingRepository(context); // Act listingRepo.AddListing(listing); int actual = context.Listings.Count(); // Assert Assert.AreEqual(expected, actual); }