Exemple #1
0
 public void UpdateArtPiece(ArtPiece piece)
 {
     String regName = "^[a - zA - Z0 - 9]{ 4,10}$";
     if (piece.Number <= 0 || piece.Name.Length <= 0)
         throw new ArgumentException();
     if (Regex.IsMatch(piece.Name, regName) || Regex.IsMatch(piece.Description, regName))
         throw new ArgumentException();
     _artDb.Update(piece);
 }
        private void FakeArtPieces()
        {
            List<ArtPiece> ArtPieces = new List<ArtPiece>();

            ArtPiece ap1 = new ArtPiece();
            ap1.ArtPieceId = 1;
            ap1.Name = "Arpiece 1";
            ap1.Number = 1234;
            ap1.Artist = "Artist1";
            ap1.PurchasePrice = 125;
            ap1.PictureUrl = "";
            ap1.Description = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu tincidunt quam, ut gravida orci. Donec tincidunt dictum molestie. Integer quis cursus ex. Nulla imperdiet lorem nibh, non pulvinar nunc facilisis ut. Phasellus fermentum sapien interdum sapien elementum pulvinar sed varius leo. Sed id arcu erat. Sed eu congue libero, id malesuada felis. Nullam tempor, tellus id porta varius, eros est dictum turpis, a luctus libero tellus mattis mi. Aliquam ultrices lorem ac odio consequat vehicula. Suspendisse eu sollicitudin metus, in eleifend odio. ";

            ArtPiece ap2 = new ArtPiece();
            ap2.ArtPieceId = 2;
            ap2.Name = "Arpiece 2";
            ap2.Number = 1234;
            ap2.Artist = "Artist2";
            ap2.PurchasePrice = 125;
            ap2.PictureUrl = "";
            ap2.Description = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu tincidunt quam, ut gravida orci. Donec tincidunt dictum molestie. Integer quis cursus ex. Nulla imperdiet lorem nibh, non pulvinar nunc facilisis ut. Phasellus fermentum sapien interdum sapien elementum pulvinar sed varius leo. Sed id arcu erat. Sed eu congue libero, id malesuada felis. Nullam tempor, tellus id porta varius, eros est dictum turpis, a luctus libero tellus mattis mi. Aliquam ultrices lorem ac odio consequat vehicula. Suspendisse eu sollicitudin metus, in eleifend odio. ";

            ArtPiece ap3 = new ArtPiece();
            ap3.ArtPieceId = 3;
            ap3.Name = "Arpiece 3";
            ap3.Number = 1234;
            ap3.Artist = "Artist3";
            ap3.PurchasePrice = 125;
            ap3.PictureUrl = "";
            ap3.Description = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu tincidunt quam, ut gravida orci. Donec tincidunt dictum molestie. Integer quis cursus ex. Nulla imperdiet lorem nibh, non pulvinar nunc facilisis ut. Phasellus fermentum sapien interdum sapien elementum pulvinar sed varius leo. Sed id arcu erat. Sed eu congue libero, id malesuada felis. Nullam tempor, tellus id porta varius, eros est dictum turpis, a luctus libero tellus mattis mi. Aliquam ultrices lorem ac odio consequat vehicula. Suspendisse eu sollicitudin metus, in eleifend odio. ";

            ArtPiece ap4 = new ArtPiece();
            ap4.ArtPieceId = 4;
            ap4.Name = "Arpiece 4";
            ap4.Number = 1234;
            ap4.Artist = "Artist4";
            ap4.PurchasePrice = 125;
            ap4.PictureUrl = "";
            ap4.Description = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu tincidunt quam, ut gravida orci. Donec tincidunt dictum molestie. Integer quis cursus ex. Nulla imperdiet lorem nibh, non pulvinar nunc facilisis ut. Phasellus fermentum sapien interdum sapien elementum pulvinar sed varius leo. Sed id arcu erat. Sed eu congue libero, id malesuada felis. Nullam tempor, tellus id porta varius, eros est dictum turpis, a luctus libero tellus mattis mi. Aliquam ultrices lorem ac odio consequat vehicula. Suspendisse eu sollicitudin metus, in eleifend odio. ";

            ArtPiece ap5 = new ArtPiece();
            ap5.ArtPieceId = 5;
            ap5.Name = "Arpiece 5";
            ap5.Number = 1234;
            ap5.Artist = "Artist5";
            ap5.PurchasePrice = 125;
            ap5.PictureUrl = "";
            ap5.Description = @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. In eu tincidunt quam, ut gravida orci. Donec tincidunt dictum molestie. Integer quis cursus ex. Nulla imperdiet lorem nibh, non pulvinar nunc facilisis ut. Phasellus fermentum sapien interdum sapien elementum pulvinar sed varius leo. Sed id arcu erat. Sed eu congue libero, id malesuada felis. Nullam tempor, tellus id porta varius, eros est dictum turpis, a luctus libero tellus mattis mi. Aliquam ultrices lorem ac odio consequat vehicula. Suspendisse eu sollicitudin metus, in eleifend odio. ";

            ArtPieces.Add(ap1);
            ArtPieces.Add(ap2);
            ArtPieces.Add(ap3);
            ArtPieces.Add(ap4);
            ArtPieces.Add(ap5);

            this._artPieces = ArtPieces;
        }
Exemple #3
0
 public void Update(ArtPiece art)
 {
     try {
         //_ac.Auctions.Attach(auc);
         _ac.Entry(art).State = EntityState.Modified;
         _ac.SaveChanges();
     }
     catch (Exception e) {
         Console.WriteLine(e);
     }
 }
Exemple #4
0
        private ArtPiece GetRandomArt()
        {
            var _artPiece = new ArtPiece() {
                Artist = "Anders",
                Description = "Hej",
                Name = "Mona Lisa",
                Number = rand.Next(1001, 9999),
                PurchasePrice = rand.Next(100, 1000)
            };

            return _artPiece;
        }
Exemple #5
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());
        }
Exemple #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 }
            };

            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());
        }
Exemple #7
0
 public void Add(ArtPiece art)
 {
     _ac.ArtPieces.Add(art);
     _ac.SaveChanges();
 }
Exemple #8
0
 public void AddArtPiece(ArtPiece piece)
 {
     _artPieceService.AddArtPiece(piece);
 }
Exemple #9
0
 public void UpdateArtPiece(ArtPiece piece)
 {
     _artPieceService.UpdateArtPiece(piece);
 }