public void Update_ValidSeller() { this.mockRepository.Setup(x => x.Update(It.IsAny <Seller>())); var services = new SellerService(this.mockRepository.Object); var seller = FakeEntityFactory.CreateSeller(); seller.Person = FakeEntityFactory.CreatePerson(); var results = services.Update(seller); Assert.AreEqual(0, results.Count); }
public void Update_NoScores() { this.mockRepository.Setup(x => x.Update(It.IsAny <Person>())); var services = new PersonService(this.mockRepository.Object); var person = FakeEntityFactory.CreatePerson(); person.UserProfile = FakeEntityFactory.CreateUserProfile(); var results = services.Update(person); Assert.AreEqual(0, results.Count); }
public void Insert_ValidAuction() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); auctionServices.Insert(auction).Should().BeEmpty(); }
public void Insert_ValidBidder() { this.mockRepository.Setup(x => x.Update(It.IsAny <Bidder>())); var services = new BidderService(this.mockRepository.Object); var bidder = FakeEntityFactory.CreateBidder(); bidder.Person = FakeEntityFactory.CreatePerson(); var results = services.Insert(bidder); Assert.AreEqual(0, results.Count); }
public void Insert_SingleCategory_NoCategoryInExcess() { var limit = int.Parse(ConfigurationManager.AppSettings.Get("MaxAuctionsStartedAndNotFinalizedForCategory")); var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); auction.Seller.Auctions = CreateActiveAuctionsWithNoCategoryInExcess().ToList(); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(0, results.Count); }
public void Insert_ValidAuctionPeriod() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); auction.BeginDate = DateTime.Now; auction.EndDate = DateTime.Now.AddDays(1); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(0, results.Count); }
public void Insert_MissingRequiredProperty() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); auction.Name = null; this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.NameRequired, res.ErrorMessage); }
public void Insert_LastValidEndDate() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); var auctionMaxPeriodInMonths = int.Parse(ConfigurationManager.AppSettings.Get("AuctionMaxPeriodInMonths")); auction.BeginDate = DateTime.Now; auction.EndDate = DateTime.Now.AddMonths(auctionMaxPeriodInMonths).AddDays(-1); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(0, results.Count); }
public void Insert_SellerBanned() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); auction.Seller.Person.BanEndDate = DateTime.Now.Date.AddDays(1); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.SellerIsBanned, res.ErrorMessage); }
public void Insert_AuctionWithMultipleCategories_NoCategoryInExcess() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); var categories = new List <Category> { FakeEntityFactory.CreateCategory(), FakeEntityFactory.CreateCategory() }; auction.Products.Add(FakeEntityFactory.CreateProduct(categories)); auction.Seller.Auctions = CreateActiveAuctionsWithMultipleCategoriesNoCategoriesInExcess().ToList(); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(0, results.Count); }
public void Update_ChangesInExpiredAuctions() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); auction.BeginDate = DateTime.Now.AddDays(-1); auction.EndDate = DateTime.Now; this.mockRepository.Setup(x => x.GetByID(It.IsAny <object>())).Returns(auction); this.mockRepository.Setup(x => x.Update(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Update(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.ChangesNotAllowedInExpiredAuctions, res.ErrorMessage); }
public void Insert_TooManyAuctionsStartedAndNotFinalized() { var auction = FakeEntityFactory.CreateAuction(); auction.Seller = FakeEntityFactory.CreateSeller(); auction.Seller.Person = FakeEntityFactory.CreatePerson(); auction.Products.Add(FakeEntityFactory.CreateProduct()); var limit = int.Parse(ConfigurationManager.AppSettings.Get("MaxAuctionsStartedAndNotFinalized")); auction.Seller.Auctions = CreateStartedAndNotFinalizedAuctions(limit + 1); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.TooManyAuctionsStartedAndNotFinalized, res.ErrorMessage); }
public void Insert_AuctionWithMultipleCategories_BothCategoriesInExcess() { 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(); this.mockRepository.Setup(x => x.Insert(It.IsAny <DomainModel.Auction>())); var auctionServices = new AuctionService(this.mockRepository.Object); var results = auctionServices.Insert(auction); Assert.AreEqual(1, results.Count); var res = results[0]; Assert.AreEqual(ErrorMessages.TooManyAuctionsStartedAndNotFinalizedForCategory, res.ErrorMessage); }