public void GivenAuctionsByASingleUser_GetAuctionsByUsername_WithDifferentUsername_ReturnsEmptyList() { // Arrange const string pera = "Pera"; const string mika = "Mika"; var userFake = new UserRepositoryFake(); userFake.CreateUser(pera, "123456"); userFake.CreateUser(mika, "654321"); var auctionService = new AuctionService(new AuctionRepositoryFake(), userFake, new AuditRepositoryFake()); auctionService.CreateAuction(pera, new AuctionItemViewModel { Description = "description", MinAmount = "0", Name = "Item 1" }); auctionService.CreateAuction(pera, new AuctionItemViewModel { Description = "description 2", MinAmount = "0", Name = "Item 2" }); // Act var allAuctionsByUsername = auctionService.GetAuctionsByUsername(mika); // Assert Assert.IsEmpty(allAuctionsByUsername); }
public void GivenTwoCreatedAuctionsByASingleUser_GetAuctionsByUsername_ReturnsListContainingBothAuctions() { // Arrange const string username = "******"; var userFake = new UserRepositoryFake(); userFake.CreateUser(username, "123456"); var auctionService = new AuctionService(new AuctionRepositoryFake(), userFake, new AuditRepositoryFake()); auctionService.CreateAuction(username, new AuctionItemViewModel { Description = "description", MinAmount = "0", Name = "Item 1" }); auctionService.CreateAuction(username, new AuctionItemViewModel { Description = "description 2", MinAmount = "0", Name = "Item 2" }); // Act var allAuctionsByUsername = auctionService.GetAuctionsByUsername(username); // Assert var auctionViewModels = allAuctionsByUsername.ToList(); var firstAuction = auctionViewModels.FirstOrDefault(); var lastAuction = auctionViewModels.LastOrDefault(); Assert.AreEqual(2, auctionViewModels.Count); Assert.AreEqual(username, firstAuction.Seller); Assert.AreEqual(username, lastAuction.Seller); }