public void TestGetAllAuc() { try { AuctionDb _db = new AuctionDb(); var list = _db.GetAll(); } catch (Exception e) { e.DebugGetLine(); Assert.Fail(); } }
public void GetAllTest() { try { Test(); var auctionCtr = new AuctionDb(_mockContext.Object); var list = auctionCtr.GetAll(); Console.WriteLine(list[0].AuctionName); Assert.AreNotEqual(0, list.Count); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }
public void AddTest() { try { Test(); var auctionCtr = new AuctionDb(_mockContext.Object); auctionCtr.Add(_auction); _auctionMock.Verify(m => m.Add(It.IsAny<Auction>()), Times.Once()); _mockContext.Verify(m => m.SaveChanges(), Times.Once()); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }
public void GetAllReadyTest() { try { Test(); var auctionCtr = new AuctionDb(_mockContext.Object); var list = auctionCtr.GetAllReady(); Assert.AreEqual(1, list.Count); } catch (Exception ex) { ex.DebugGetLine(); Assert.Fail(); } }
public void DeleteTest() { try { Test(); var auctionCtr = new AuctionDb(_mockContext.Object); auctionCtr.Delete(_auction.AuctionId); _lotMock.Verify(m => m.RemoveRange(It.IsAny<List<Lot>>()), Times.Once); _auctionMock.Verify(m => m.Remove(It.IsAny<Auction>()), Times.Once); _mockContext.Verify(m => m.SaveChanges(), Times.Once); auctionCtr.Delete(_bidAuction.AuctionId); _lotMock.Verify(m => m.RemoveRange(It.IsAny<List<Lot>>()), Times.Once); _auctionMock.Verify(m => m.Remove(It.IsAny<Auction>()), Times.Once); _mockContext.Verify(m => m.SaveChanges(), Times.Exactly(2)); Assert.IsTrue(true); } catch (Exception e) { e.DebugGetLine(); Assert.Fail(); } }
public void GetByIdTest() { bool test = false; try { Test(); var auctionCtr = new AuctionDb(_mockContext.Object); var ac = auctionCtr.GetById(1); test = true; auctionCtr.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 auctionCtr = new AuctionDb(_mockContext.Object); _auction.AuctionName = "Kage"; auctionCtr.Update(_auction); var list = auctionCtr.GetAll(); Assert.AreEqual("Kage", list[0].AuctionName); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }