Ejemplo n.º 1
0
        public void TestRemoveNonExistingAisle()
        {
            var aisleManagerMock = new Mock <IAisleManager>();
            var shelfManagerMock = new Mock <IShelfManager>();

            aisleManagerMock.Setup(m =>
                                   m.GetAisleByAisleNumber(It.IsAny <int>()))
            .Returns((Aisle)null);

            var libraryAPI  = new LibraryAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = libraryAPI.RemoveAisle(4);

            Assert.AreEqual(AisleStatusCodes.NoSuchAisle, successfull);
            aisleManagerMock.Verify(m =>
                                    m.RemoveAisle(It.IsAny <int>()), Times.Never);
        }
Ejemplo n.º 2
0
        public void TestRemoveEmptyAisle()
        {
            var aisleManagerMock = new Mock <IAisleManager>();
            var shelfManagerMock = new Mock <IShelfManager>();

            aisleManagerMock.Setup(m =>
                                   m.GetAisleByAisleNumber(It.IsAny <int>()))
            .Returns(new Aisle
            {
                AisleNumber = 4,
                Shelf       = new List <Shelf>()
            });

            var libraryAPI  = new LibraryAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = libraryAPI.RemoveAisle(4);

            Assert.AreEqual(AisleStatusCodes.Ok, successfull);
            aisleManagerMock.Verify(m =>
                                    m.RemoveAisle(It.IsAny <int>()), Times.Once);
        }
Ejemplo n.º 3
0
        public void TestRemoveAisleWithOneShelf()
        {
            var aisleManagerMock = new Mock <IAisleManager>();
            var shelfManagerMock = new Mock <IShelfManager>();

            aisleManagerMock.Setup(m =>
                                   m.GetAisleByAisleNumber(It.IsAny <int>()))
            .Returns(new Aisle
            {
                AisleNumber = 4,
                Shelf       = new List <Shelf>
                {
                    new Shelf()
                }
            });

            var libraryAPI  = new LibraryAPI(aisleManagerMock.Object, shelfManagerMock.Object, null, null);
            var successfull = libraryAPI.RemoveAisle(4);

            Assert.AreEqual(RemoveAisleErrorCodes.AisleHasShelves, successfull);
            aisleManagerMock.Verify(m =>
                                    m.RemoveAisle(It.IsAny <int>()), Times.Never);
        }