public void CreateStuff() { ArtPieceDb _db = new ArtPieceDb(); for (int i = 0; i < 20; i++) { _db.Add(GetRandomArt()); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }