示例#1
0
        public void TestRemoveNoneExistingSection()
        {
            var sectionManagerMock = new Mock <ISectionManager>();
            var shelfManagerMock   = new Mock <IShelfManager>();
            var bookManagerMock    = new Mock <IBookManager>();

            sectionManagerMock.Setup(m =>
                                     m.GetSectionBySectionNumber(It.IsAny <int>()))
            .Returns((Section)null);

            var libraryAPI  = new LibraryAPI(sectionManagerMock.Object, shelfManagerMock.Object, bookManagerMock.Object);
            var successfull = libraryAPI.RemoveSection(1);

            Assert.AreEqual(RemoveSectionCodes.NoSuchSection, successfull);
            sectionManagerMock.Verify(m =>
                                      m.RemoveSection(It.IsAny <int>()), Times.Never);
        }
示例#2
0
        public void TestRemoveEmptySection()
        {
            var sectionManagerMock = new Mock <ISectionManager>();
            var shelfManagerMock   = new Mock <IShelfManager>();
            var bookManagerMock    = new Mock <IBookManager>();

            sectionManagerMock.Setup(m =>
                                     m.GetSectionBySectionNumber(It.IsAny <int>()))
            .Returns(new Section
            {
                SectionNumber = 1,
                Shelfs        = new List <Shelf>()
            });

            var libraryAPI  = new LibraryAPI(sectionManagerMock.Object, shelfManagerMock.Object, bookManagerMock.Object);
            var successfull = libraryAPI.RemoveSection(1);

            Assert.AreEqual(RemoveSectionCodes.Ok, successfull);
            sectionManagerMock.Verify(m =>
                                      m.RemoveSection(It.IsAny <int>()), Times.Once);
        }