public void TestGetScrapListWithNoShelf() { var sectionManagerMock = new Mock <ISectionManager>(); var shelfManagerMock = new Mock <IShelfManager>(); var bookManagerMock = new Mock <IBookManager>(); var scrapListManagerMock = new Mock <IScrapListManager>(); var scrapListAPI = new ScrapListAPI(sectionManagerMock.Object, shelfManagerMock.Object, bookManagerMock.Object, scrapListManagerMock.Object); sectionManagerMock.Setup(m => m.GetSectionBySectionNumber(It.IsAny <int>())) .Returns(new Section { SectionID = 10, }); bookManagerMock.Setup(m => m.GetBookByName(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <int>())) .Returns(new Book { BookID = 30, BookName = "Clean Code", BookCondition = 1, InLibrary = true, }); var successfull = scrapListAPI.GetScrapList(0, 0, "Clean Code", true, 1); Assert.AreEqual(GetScrapListCodes.HasNoShelfs, successfull); sectionManagerMock.Verify( m => m.GetScrapList(), Times.Never()); }
public void TestGetScrapListWithNoBooks() { var sectionManagerMock = new Mock <ISectionManager>(); var shelfManagerMock = new Mock <IShelfManager>(); var bookManagerMock = new Mock <IBookManager>(); var scrapListManagerMock = new Mock <IScrapListManager>(); var scrapListAPI = new ScrapListAPI(sectionManagerMock.Object, shelfManagerMock.Object, bookManagerMock.Object, scrapListManagerMock.Object); sectionManagerMock.Setup(m => m.GetSectionBySectionNumber(It.IsAny <int>())) .Returns(new Section { SectionID = 10, }); shelfManagerMock.Setup(m => m.GetShelfByShelfNumber(It.IsAny <int>())) .Returns(new Shelf { SectionID = 10, ShelfID = 20, }); var successfull = scrapListAPI.GetScrapList(0, 0, "Clean Code", true, 1); Assert.AreEqual(GetScrapListCodes.HasNoBooks, successfull); sectionManagerMock.Verify( m => m.GetScrapList(), Times.Never()); }
public void TestGetScrapListWithBorrowedBook() { var sectionManagerMock = new Mock <ISectionManager>(); var shelfManagerMock = new Mock <IShelfManager>(); var bookManagerMock = new Mock <IBookManager>(); var scrapListManagerMock = new Mock <IScrapListManager>(); var scrapListAPI = new ScrapListAPI(sectionManagerMock.Object, shelfManagerMock.Object, bookManagerMock.Object, scrapListManagerMock.Object); sectionManagerMock.Setup(m => m.GetSectionBySectionNumber(It.Is <int>(i => i == 11))) .Returns(new Section { SectionID = 10, SectionNumber = 11, }); shelfManagerMock.Setup(m => m.GetShelfByShelfNumber(It.Is <int>(i => i == 21))) .Returns(new Shelf { SectionID = 10, ShelfID = 20, ShelfNumber = 21 }); bookManagerMock.Setup(m => m.GetBookByName(It.Is <string>(s => s == "Clean Code"), It.Is <bool>(b => b == false), It.Is <int>(i => i == 1))) .Returns(new Book { ShelfID = 20, BookID = 30, BookName = "Clean Code", BookCondition = 1, InLibrary = false, }); var successfull = scrapListAPI.GetScrapList(11, 21, "Clean Code", false, 1); Assert.AreEqual(GetScrapListCodes.BookIsBorrowed, successfull); sectionManagerMock.Verify( m => m.GetScrapList(), Times.Never()); }