예제 #1
0
        public void UpdateAuction(Auction auction)
        {
            String regName = "^[a - zA - Z0 - 9]{ 4,10}$";
            if (Regex.IsMatch(auction.AuctionName, regName) || auction.AuctionName.Length < 1)
                throw new ArgumentException();

            _ctr.Update(auction);
        }
예제 #2
0
        public void Add(Auction ac)
        {
            if (ac.Lots.Count <= 0) {
                throw new Exception("You failed");
            }

            _ac.Auctions.Add(ac);
            _ac.SaveChanges();
        }
예제 #3
0
        public void Update(Auction auction)
        {
            String regName = "^[a - zA - Z0 - 9]{ 4,10}$";
            if (Regex.IsMatch(auction.AuctionName, regName) || auction.AuctionName.Length > 1)
                throw new ArgumentException();
            if (auction.LotDuration.TotalSeconds > 0 || auction.LotDuration.TotalMinutes > 120 || auction.Lots.Count > 0)
                throw new ArgumentException();

            _ctr.Update(auction);
        }
예제 #4
0
 public void Update(Auction auc)
 {
     if (auc.Lots.Count <= 0) {
         throw new Exception("You failed");
     }
     try {
         //_ac.Auctions.Attach(auc);
         _ac.Entry(auc).State = EntityState.Modified;
         _ac.SaveChanges();
     }
     catch (Exception e) {
         Console.WriteLine(e);
     }
 }
예제 #5
0
        public void AddAuction(Auction auction)
        {
            //String regName = "^[a - zA - Z0 - 9]{ 4,10}$";

            //if (Regex.IsMatch(auction.AuctionName, regName) || auction.AuctionName.Length > 1)
            //    throw new ArgumentException();
            //if(auction.LotDuration.TotalSeconds > 0)
            //    throw new ArgumentException();
            //if (auction.Lots.Count < 0)
            //    throw new ArgumentException();
            //if (auction.LotDuration.TotalMinutes > 120)
            //    throw new ArgumentException();

            _ctr.Add(auction);
        }
예제 #6
0
        private void Test()
        {
            _auctionMock = new Mock<DbSet<Auction>>();
            _lotMock = new Mock<DbSet<Lot>>();
            _artPieceMock = new Mock<DbSet<ArtPiece>>();
            _mockContext = new Mock<AuctionContext>();

            _mockContext.Setup(m => m.Auctions).Returns(_auctionMock.Object);
            _mockContext.Setup(m => m.Lots).Returns(_lotMock.Object);
            _mockContext.Setup(m => m.ArtPieces).Returns(_artPieceMock.Object);

            _artPiece = new ArtPiece() {
                ArtPieceId = 1,
                Artist = "Anders",
                Description = "Hej",
                Name = "Mona Lisa",
                Number = 1001,
                PurchasePrice = 10
            };

            _lot = new Lot() {
                LotId = 1,
                MinBid = 20,
                Position = 1,
                ArtPiece = _artPiece
            };

            _auction = new Auction {
                AuctionId = 1,
                AuctionName = "Test Auction",
                CreationDate = DateTime.Now,
                LotDuration = TimeSpan.FromMinutes(30),
                Multiplier = 3,
                Status = Status.Ready,
                Lots = new List<Lot>() { _lot }
            };

            _bidArtPiece = new ArtPiece() {
                ArtPieceId = 2,
                Artist = "Anders",
                Description = "Hej",
                Name = "Mona Lisa",
                Number = 1001,
                PurchasePrice = 10
            };

            Bid bid = new Bid() {
                Amount = 20,
                Bidder = new Member() { MemberId = 1},
                BidId = 1
            };

            _bidLot = new Lot() {
                LotId = 2,
                MinBid = 20,
                Position = 1,
                ArtPiece = _bidArtPiece,
                Bids = new List<Bid>() { bid}
            };

            _bidAuction = new Auction {
                AuctionId = 5,
                AuctionName = "Test Auction",
                CreationDate = DateTime.Now,
                LotDuration = TimeSpan.FromMinutes(30),
                Multiplier = 3,
                Status = Status.Ready,
                Lots = new List<Lot>() { _bidLot }
            };

            _auctionMock.AddQueryData(new List<Auction> { _auction, _bidAuction }.AsQueryable());
        }
예제 #7
0
        private void Test()
        {
            _auctionMock = new Mock<DbSet<Auction>>();
            _lotMock = new Mock<DbSet<Lot>>();
            _artPieceMock = new Mock<DbSet<ArtPiece>>();
            _mockContext = new Mock<AuctionContext>();

            _mockContext.Setup(m => m.Auctions).Returns(_auctionMock.Object);
            _mockContext.Setup(m => m.Lots).Returns(_lotMock.Object);
            _mockContext.Setup(m => m.ArtPieces).Returns(_artPieceMock.Object);

            _artPiece = new ArtPiece() {
                ArtPieceId = 1,
                Artist = "Anders",
                Description = "Hej",
                Name = "Mona Lisa",
                Number = 1001,
                PurchasePrice = 10
            };

            _lot = new Lot() {
                LotId = 1,
                MinBid = 20,
                Position = 1,
                ArtPiece = _artPiece
            };

            _auction = new Auction {
                AuctionId = 1,
                AuctionName = "Test Auction",
                CreationDate = DateTime.Now,
                LotDuration = TimeSpan.FromMinutes(30),
                Multiplier = 3,
                Status = Status.Ready,
                Lots = new List<Lot>() { _lot }
            };

            var data = new List<ArtPiece>
            {
                _artPiece
            }.AsQueryable();

            _artPieceMock.As<IQueryable<ArtPiece>>().Setup(m => m.Provider).Returns(data.Provider);
            _artPieceMock.As<IQueryable<ArtPiece>>().Setup(m => m.Expression).Returns(data.Expression);
            _artPieceMock.As<IQueryable<ArtPiece>>().Setup(m => m.ElementType).Returns(data.ElementType);
            _artPieceMock.As<IQueryable<ArtPiece>>().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());
        }
예제 #8
0
 public List<Lot> GetAllLotsByAuction(Auction auction)
 {
     return _lotService.GetAllLotsByAuction(auction);
 }
예제 #9
0
 public void AddAuction(Auction auction)
 {
     _auctionService.AddAuction(auction);
 }
예제 #10
0
 public void UpdateAuction(Auction auction)
 {
     _auctionService.UpdateAuction(auction);
 }
예제 #11
0
 public List<Lot> GetAllLotsByAuction(Auction auction)
 {
     return _lotDb.GetAllByAuction(auction);
 }