示例#1
0
        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();
        }
示例#2
0
        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();
        }
示例#3
0
        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>();
        }
示例#4
0
        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>();
        }
示例#5
0
        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();
        }
示例#6
0
        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);
        }
示例#7
0
        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();
            }
        }