Example #1
0
 public void CreateStuff()
 {
     ArtPieceDb _db = new ArtPieceDb();
     for (int i = 0; i < 20; i++) {
         _db.Add(GetRandomArt());
     }
 }
Example #2
0
        public void GetAllTest()
        {
            try {
                Test();
                var artPieceCtr = new ArtPieceDb(_mockContext.Object);

                var list = artPieceCtr.GetAll();

                Assert.AreNotEqual(0, list.Count);
            } catch (Exception e) {
                Console.WriteLine(e);
                Assert.Fail();
            }
        }
Example #3
0
        public void AddTest()
        {
            try {
                Test();
                var artPieceCtr = new ArtPieceDb(_mockContext.Object);

                artPieceCtr.Add(_artPiece);

                _artPieceMock.Verify(m => m.Add(It.IsAny<ArtPiece>()), Times.Once());
                _mockContext.Verify(m => m.SaveChanges(), Times.Once());
            } catch (Exception e) {
                Console.WriteLine(e);
                Assert.Fail();
            }
        }
Example #4
0
        public void DeleteTest()
        {
            try {
                Test();
                var artPieceCtr = new ArtPieceDb(_mockContext.Object);

                artPieceCtr.Delete(_auction.AuctionId);

                _artPieceMock.Verify(m => m.Remove(It.IsAny<ArtPiece>()), Times.Once);
                _mockContext.Verify(m => m.SaveChanges(), Times.Once);

                Assert.IsTrue(true);
            } catch (Exception e) {
                e.DebugGetLine();
                Assert.Fail();
            }
        }
Example #5
0
        public void GetByIdTest()
        {
            bool test = false;
            try {
                Test();
                var artPieceCtr = new ArtPieceDb(_mockContext.Object);

                var ap = artPieceCtr.GetById(1);

                test = true;

                artPieceCtr.GetById(2);

            } catch (NullReferenceException) {
                if (!test) {
                    Assert.Fail();
                } else {
                    Assert.IsTrue(true);
                }
            } catch (Exception e) {
                e.DebugGetLine();
                Assert.Fail();
            }
        }
Example #6
0
        public void UpdateTest()
        {
            try {
                Test();
                var artPieceCtr = new ArtPieceDb(_mockContext.Object);

                _artPiece.Artist = "Søren";

                artPieceCtr.Update(_artPiece);

                var list = artPieceCtr.GetAll();

                Assert.AreEqual("Søren", list[0].Artist);
            } catch (Exception e) {
                Console.WriteLine(e);
                Assert.Fail();
            }
        }