public void GetAllByAuctionTest() { try { Test(); var lotCtr = new LotDb(_mockContext.Object); var list = lotCtr.GetAllByAuction(_auction); Assert.AreNotEqual(0, list.Count); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }
public void AddTest() { try { Test(); var lotCtr = new LotDb(_mockContext.Object); lotCtr.Add(_lot); _lotMock.Verify(m => m.Add(It.IsAny<Lot>()), Times.Once()); _mockContext.Verify(m => m.SaveChanges(), Times.Once()); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }
public void DeleteTest() { try { Test(); var lotCtr = new LotDb(_mockContext.Object); lotCtr.Delete(_lot.LotId); _lotMock.Verify(m => m.Remove(It.IsAny<Lot>()), 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 lotCtr = new LotDb(_mockContext.Object); var lot = lotCtr.GetById(1); test = true; lotCtr.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 lotCtr = new LotDb(_mockContext.Object); _lot.MinBid = 50; lotCtr.Update(_lot); var list = lotCtr.GetAllByAuction(_auction); Assert.AreEqual(50, list[0].MinBid); } catch (Exception e) { Console.WriteLine(e); Assert.Fail(); } }