/// <summary> /// The CreateStartedAndNotFinalizedAuctions. /// </summary> /// <param name="n">The n<see cref="int"/>.</param> /// <returns>The <see cref="List{Auction}"/>.</returns> private List <Auction> CreateStartedAndNotFinalizedAuctions(int n) { var auctions = new List <Auction>(); for (int i = 0; i < n; ++i) { var auction = CreateActiveAuction(); var product = FakeEntityFactory.CreateProduct(); product.Categories.Add(FakeEntityFactory.CreateCategory()); product.Sellers.Add(seller); auction.Products.Add(product); auctions.Add(auction); } return(auctions); }
public void Insert_AuctionsWithMultipleCategories_NoCategoryInExcess_ShouldNotFail() { SetUpAuction(); var categories = new List <Category> { FakeEntityFactory.CreateCategory(), FakeEntityFactory.CreateCategory() }; var product = FakeEntityFactory.CreateProduct(categories); product.Sellers.Add(seller); auction.Products.Add(product); auction.Seller.Auctions = CreateActiveAuctionsWithMultipleCategoriesNoCategoriesInExcess().ToList(); var results = auctionServices.Insert(auction); Assert.AreEqual(0, results.Count); }
/// <summary> /// The CreateActiveAuctionsWithMultipleCategoriesNoCategoriesInExcess. /// </summary> /// <returns>The <see cref="IList{Auction}"/>.</returns> private IList <Auction> CreateActiveAuctionsWithMultipleCategoriesNoCategoriesInExcess() { var limit = int.Parse(ConfigurationManager.AppSettings.Get("MaxAuctionsStartedAndNotFinalized")); var activeAuctions = new List <Auction>(); for (int i = 0; i < limit; ++i) { var categories = new List <Category> { FakeEntityFactory.CreateCategory(), FakeEntityFactory.CreateCategory() }; var product = FakeEntityFactory.CreateProduct(categories); product.Sellers.Add(this.seller); var activeAuction = CreateActiveAuction(); activeAuction.Products.Add(product); activeAuctions.Add(activeAuction); } return(activeAuctions); }
/// <summary> /// The CreateActiveAuctionsWithCategoriesInExcess. /// </summary> /// <param name="commonCategories">The commonCategories<see cref="List{Category}"/>.</param> /// <returns>The <see cref="IList{Auction}"/>.</returns> private IList <Auction> CreateActiveAuctionsWithCategoriesInExcess(List <Category> commonCategories) { var limit = int.Parse(ConfigurationManager.AppSettings.Get("MaxAuctionsStartedAndNotFinalizedForCategory")); var activeAuctions = new List <Auction>(); for (int i = 0; i <= limit; ++i) { var withAddedCategories = commonCategories.Concat(new List <Category> { FakeEntityFactory.CreateCategory(), FakeEntityFactory.CreateCategory() }); var product = FakeEntityFactory.CreateProduct(withAddedCategories.ToList()); product.Sellers.Add(this.seller); var activeAuction = CreateActiveAuction(); activeAuction.Products.Add(product); activeAuctions.Add(activeAuction); } return(activeAuctions); }
public void Insert_AuctionWithSingleCategory_CategoryInExcess_ShouldFail() { SetUpAuction(); var commonCategories = new List <Category> { FakeEntityFactory.CreateCategory() }; product.Categories = commonCategories; auction.Products.Add(product); auction.Seller.Auctions = CreateActiveAuctionsWithOneCategoryInExcess(commonCategories).ToList(); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.TooManyAuctionsStartedAndNotFinalizedForCategory, res.ErrorMessage); }
public void Insert_AuctionWithMultipleCategories_BothCategoriesInExcess_ShouldFail() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); var commonCategories = new List <Category> { FakeEntityFactory.CreateCategory(), FakeEntityFactory.CreateCategory() }; auction.Products.Add(FakeEntityFactory.CreateProduct(commonCategories)); auction.Seller.Auctions = CreateActiveAuctionsWithCategoriesInExcess(commonCategories).ToList(); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.TooManyAuctionsStartedAndNotFinalizedForCategory, res.ErrorMessage); }
public void Insert_AuctionsWithMultipleCategories_OneCategoryInExcess_ShouldFail() { SetUpAuction(); var commonCategories = new List <Category> { FakeEntityFactory.CreateCategory() }; var product = FakeEntityFactory.CreateProduct(commonCategories); product.Sellers.Add(this.seller); auction.Products = new List <Product> { product }; auction.Seller.Auctions = CreateActiveAuctionsWithCategoriesInExcess(commonCategories).ToList(); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.TooManyAuctionsStartedAndNotFinalizedForCategory, res.ErrorMessage); }
/// <summary> /// The CreateFutureAuction. /// </summary> /// <returns>The <see cref="Auction"/>.</returns> private Auction CreateFutureAuction() { var userProfile = FakeEntityFactory.CreateUserProfile(); var person = FakeEntityFactory.CreatePerson(); person.Id = userProfile.Id; person.UserProfile = userProfile; var product = FakeEntityFactory.CreateProduct(); var category = FakeEntityFactory.CreateCategory(); product.Sellers.Add(this.seller); product.Categories.Add(category); var auction = FakeEntityFactory.CreateAuction(); auction.Seller = this.seller; auction.Products.Add(product); auction.BeginDate = DateTime.Now.AddDays(1); auction.EndDate = DateTime.Now.AddDays(2); auction.Active = false; return(auction); }
public void Initialize() { this.userProfile = FakeEntityFactory.CreateUserProfile(); this.person = FakeEntityFactory.CreatePerson(); this.seller = FakeEntityFactory.CreateSeller(); this.auction = FakeEntityFactory.CreateAuction(); this.bidder = FakeEntityFactory.CreateBidder(); this.product = FakeEntityFactory.CreateProduct(); this.category = FakeEntityFactory.CreateCategory(); this.userProfileServices = new UserProfileService(new UserProfileRepository()); this.personServices = new PersonService(new PersonRepository()); this.bidderServices = new BidderService(new BidderRepository()); this.sellerServices = new SellerService(new SellerRepository()); this.categoryServices = new CategoryService(new CategoryRepository()); this.bidServices = new BidService(new BidRepository()); this.productServices = new ProductService(new ProductRepository()); this.auctionServices = new AuctionService(new AuctionRepository()); using (var auctionDBContext = new AuctionDBContext()) { auctionDBContext.Database.Delete(); } }