public void GetByID_EntityNotFound() { this.mockRepository.Setup(x => x.GetByID(It.IsAny <object>())); var services = new BidderService(this.mockRepository.Object); services.GetByID(0).Should().BeNull(); }
public void Delete_Entity() { this.mockRepository.Setup(x => x.Delete(It.IsAny <Bidder>())); var bidderServices = new BidderService(this.mockRepository.Object); Action act = () => bidderServices.Delete(new Bidder()); act.Should().NotThrow(); }
public void Delete_Null() { this.mockRepository.Setup(x => x.Delete(It.IsAny <Bidder>())).Throws <NullReferenceException>(); var bidderServices = new BidderService(this.mockRepository.Object); Action act = () => bidderServices.Delete(null); act.Should().Throw <NullReferenceException>(); }
public void Insert_Null() { this.mockRepository.Setup(x => x.Insert(It.IsAny <Bidder>())).Throws <ArgumentNullException>(); var bidderServices = new BidderService(this.mockRepository.Object); Action act = () => bidderServices.Insert(null); act.Should().Throw <ArgumentNullException>(); }
public void GetAll_Empty() { this.mockRepository.Setup( x => x.Get( It.IsAny <Expression <Func <Bidder, bool> > >(), It.IsAny <Func <IQueryable <Bidder>, IOrderedQueryable <Bidder> > >(), It.IsAny <string>())).Returns(new List <Bidder>()); var services = new BidderService(this.mockRepository.Object); services.GetAll().Should().BeEmpty(); }
public void Update_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.Update(bidder); Assert.AreEqual(0, results.Count); }
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(); } }