Exemple #1
0
        //TEST ADD AISLE:
        private static bool AddAisleNumberOne(Mock <IAisleManager> aisleManagerMock)
        {
            var storageAPI  = new StorageAPI(aisleManagerMock.Object, null);
            var successfull = storageAPI.AddAisle(1);

            return(successfull);
        }
Exemple #2
0
        //TEST ADD SHELF:
        private AddShelfStatusCodes AddShelfNumberOne(Mock <IShelfManager> shelfManagerMock)
        {
            var aisleManagerMock = SetupMock(new Aisle {
                AisleNumber = 1
            });
            var storageAPI  = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = storageAPI.AddShelf(1, 1);

            return(successfull);
        }
Exemple #3
0
        public void ChangeShelfNumberNoSuchShelf()
        {
            var shelfManagerMock = SetupMock((Shelf)null);

            var storageAPI = new StorageAPI(null, shelfManagerMock.Object);
            var result     = storageAPI.ChangeShelfNumber(1, 2);

            Assert.AreEqual(ChangeShelfNumberStatusCodes.NoSuchShelf, result);
            shelfManagerMock.Verify(m =>
                                    m.ChangeShelfNumber(1, 2), Times.Never());
        }
Exemple #4
0
        public void RemoveNonExistingAisle()
        {
            var aisleManagerMock = SetupMock((Aisle)null);
            var shelfManagerMock = new Mock <IShelfManager>();

            var storageAPI  = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = storageAPI.RemoveAisle(4);

            Assert.AreEqual(RemoveAisleErrorCodes.NoSuchAisle, successfull);
            aisleManagerMock.Verify(m =>
                                    m.RemoveAisle(It.IsAny <int>()), Times.Never);
        }
Exemple #5
0
        public void RemoveNonExistingShelf()
        {
            var aisleManagerMock = new Mock <IAisleManager>();
            var shelfManagerMock = SetupMock((Shelf)null);

            var storageAPI  = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = storageAPI.RemoveShelf(4, 1);

            Assert.AreEqual(RemoveShelfStatusCodes.NoSuchShelf, successfull);
            shelfManagerMock.Verify(m =>
                                    m.RemoveShelf(It.IsAny <int>()), Times.Never);
        }
Exemple #6
0
        public void MoveShelfNoSuchAisle()
        {
            var aisleManagerMock = SetupMock((Aisle)null);
            var shelfManagerMock = new Mock <IShelfManager>();

            var storageAPI = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var result     = storageAPI.MoveShelf(1, 1);

            Assert.AreEqual(MoveShelfStatusCodes.NoSuchAisle, result);
            shelfManagerMock.Verify(m =>
                                    m.MoveShelf(2, 2), Times.Never());
        }
Exemple #7
0
        public void RemoveEmptyAisle()
        {
            var aisleManagerMock = SetupMock(new Aisle
            {
                AisleNumber = 4,
                Shelfs      = new List <Shelf>()
            });
            var shelfManagerMock = new Mock <IShelfManager>();

            var storageAPI  = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = storageAPI.RemoveAisle(4);

            Assert.AreEqual(RemoveAisleErrorCodes.Ok, successfull);
            aisleManagerMock.Verify(m =>
                                    m.RemoveAisle(It.IsAny <int>()), Times.Once);
        }
Exemple #8
0
        public void RemoveEmptyShelf()
        {
            var aisleManagerMock = new Mock <IAisleManager>();
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfNumber = 1,
                Books       = new List <Book>()
            });

            var storageAPI  = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = storageAPI.RemoveShelf(1, 2);

            Assert.AreEqual(RemoveShelfStatusCodes.Ok, successfull);
            shelfManagerMock.Verify(m =>
                                    m.RemoveShelf(It.IsAny <int>()), Times.Once);
        }
Exemple #9
0
        public void MoveShelfOk()
        {
            var aisleManagerMock = SetupMock(new Aisle {
                AisleID = 2
            });
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfID = 2,
                Aisle   = new Aisle()
            });

            var storageAPI = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var result     = storageAPI.MoveShelf(1, 1);

            Assert.AreEqual(MoveShelfStatusCodes.Ok, result);
            shelfManagerMock.Verify(m =>
                                    m.MoveShelf(2, 2), Times.Once());
        }
Exemple #10
0
        public void RemoveShelfWithOneBook()
        {
            var aisleManagerMock = new Mock <IAisleManager>();
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfNumber = 4,
                Books       = new List <Book>
                {
                    new Book()
                }
            });

            var storageAPI  = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var successfull = storageAPI.RemoveShelf(4, 1);

            Assert.AreEqual(RemoveShelfStatusCodes.ShelfHasBooks, successfull);
            shelfManagerMock.Verify(m =>
                                    m.RemoveShelf(It.IsAny <int>()), Times.Never);
        }
Exemple #11
0
        public void MoveShelfAlreadyInThatAisle()
        {
            var currentAisle = new Aisle {
                AisleNumber = 2
            };
            var aisleManagerMock = SetupMock(currentAisle);
            var shelfManagerMock = SetupMock(new Shelf
            {
                ShelfID = 2,
                Aisle   = currentAisle
            });

            var storageAPI = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var result     = storageAPI.MoveShelf(2, 2);

            Assert.AreEqual(MoveShelfStatusCodes.ShelfAlreadyInThatAisle, result);
            shelfManagerMock.Verify(m =>
                                    m.MoveShelf(2, 2), Times.Never());
        }
Exemple #12
0
        /// <inheritdoc/>
        public void StartGame(StartGameRequest request)
        {
            try
            {
                lock (this.Padlock)
                {
                    if (this.LobbyMode != Mode.LobbyMode)
                    {
                        return;
                    }

                    this.Difficulty  = request.Difficulty;
                    this.LobbyMode   = Mode.InputMode;
                    this.RoundNumber = 1;

                    this.Broadcaster.GameMode(request.StageNumber, (byte)request.Difficulty);
                    this.Broadcaster.InputRound(this.RoundNumber);

                    EnemyDefinitions enemies = EnemyDefinitions.Parse(StorageAPI.DownloadEnemies());
                    RoundDefinitions rounds  = RoundDefinitions.Parse(StorageAPI.DownloadRounds());
                    Stage            stage   = Stage.Parse(StorageAPI.DownloadStage(request.StageNumber));
                    TowerDefinitions towers  = TowerDefinitions.Parse(StorageAPI.DownloadTowers());
                    this.NumberOfRounds = rounds.Rounds.Count;
                    this.EcsContainer   = new EcsContainer(
                        this.Broadcaster,
                        request.Difficulty,
                        enemies,
                        rounds,
                        stage,
                        towers
                        );
                    this.EcsContainer.UpdateClientSystem.UpdateClients();
                }
            }
            finally
            {
                this.ResetInactivityTimer();
            }
        }
Exemple #13
0
        public void ChangeShelfNumberToSameShelfNumber()
        {
            var aisleManagerMock = SetupMock(new Aisle {
                AisleID = 1
            });
            var shelfManagerMock = new Mock <IShelfManager>();

            shelfManagerMock.Setup(m =>
                                   m.GetShelfByShelfId(It.IsAny <int>()))
            .Returns(new Shelf
            {
                ShelfID     = 1,
                Aisle       = new Aisle(),
                ShelfNumber = 1
            });

            var storageAPI = new StorageAPI(aisleManagerMock.Object, shelfManagerMock.Object);
            var result     = storageAPI.ChangeShelfNumber(1, 1);

            Assert.AreEqual(ChangeShelfNumberStatusCodes.CanNotChangeToSameNumber, result);
            shelfManagerMock.Verify(m =>
                                    m.ChangeShelfNumber(1, 1), Times.Never());
        }