示例#1
0
        public void TestAddShelfAlreadyExist()
        {
            var pathManagerMock  = new Mock <IPathManager>();
            var shelfManagerMock = new Mock <IShelfManager>();


            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfNumber(It.IsAny <int>(), (It.IsAny <int>())))
            .Returns(new Shelf
            {
                ShelfNumber = 2
            });

            pathManagerMock.Setup(m =>
                                  m.GetPathByPathID(It.IsAny <int>()))
            .Returns(new Path
            {
                PathNumber = 2
            });

            var pathAndShelfAPI = new PathAndShelfAPI(pathManagerMock.Object, shelfManagerMock.Object, null);
            var result          = pathAndShelfAPI.AddShelf(2, 2);

            Assert.AreEqual(ErrorCodesAddShelf.ShelfAlreadyExist, result);
            shelfManagerMock.Verify(m =>
                                    m.AddShelf(2, 2), Times.Never());
        }
示例#2
0
        public void TestAddShelfPathDoesNotExist()
        {
            var shelfManagerMock = new Mock <IShelfManager>();
            var pathManagerMock  = new Mock <IPathManager>();
            var shelf            = new Shelf
            {
                ShelfNumber = 1
            };
            var pathAndShelfAPI = new PathAndShelfAPI(pathManagerMock.Object, shelfManagerMock.Object, null);
            var result          = pathAndShelfAPI.AddShelf(1, 2);

            Assert.AreEqual(ErrorCodesAddShelf.PathDoesNotExist, result);
            shelfManagerMock.Verify(m =>
                                    m.AddShelf(It.IsAny <int>(), (It.IsAny <int>())), Times.Never);
        }
示例#3
0
        private ErrorCodesAddShelf AddShelfNumberOne(Mock <IShelfManager> ShelfManagerMock)
        {
            var pathManagerMock = new Mock <IPathManager>();

            pathManagerMock.Setup(m =>
                                  m.GetPathByPathID(It.IsAny <int>()))
            .Returns(new Path
            {
                PathID = 1
            });

            var pathAndShelfAPI = new PathAndShelfAPI(pathManagerMock.Object, ShelfManagerMock.Object, null);
            var successfull     = pathAndShelfAPI.AddShelf(1, 1);

            return(successfull);
        }