Esempio n. 1
0
        /// <summary>
        /// Остановка пасеки.
        /// </summary>
        private void Stop()
        {
            IApiaryState   lastState    = this.apiary.Stop();
            ApiaryXmlState xmlLastState = ApiaryXmlState.CopyFrom(lastState);

            xmlLastState.SaveInCache();
            this.isWorking = false;
            this.RefreshCanExecuteCommands();
        }
Esempio n. 2
0
        public void ApiaryXmlState_ClearCache()
        {
            ApiaryXmlState state
                = ApiaryXmlState.LoadState();

            int randomValue = new Random().Next(1, 1000);

            state.BeehiveStates.First(st => st.BeehiveNumber == 1)
            .WorkerBeesCount = randomValue;

            state.SaveInCache();

            ApiaryXmlState.ClearCache();

            ApiaryXmlState standardState
                = ApiaryXmlState.LoadState();

            int workersInFirstBeehive = standardState
                                        .BeehiveStates.First(st => st.BeehiveNumber == 1)
                                        .WorkerBeesCount;

            Assert.AreNotEqual(randomValue, workersInFirstBeehive);
        }
Esempio n. 3
0
        public void ApiaryXmlState_SaveState()
        {
            ApiaryXmlState beforeUpdating
                = ApiaryXmlState.LoadState();

            int randomValue = new Random().Next(1, 1000);

            beforeUpdating.BeehiveStates.First(st =>
                                               st.BeehiveNumber == 1)
            .WorkerBeesCount = randomValue;

            beforeUpdating.SaveInCache();

            ApiaryXmlState afterUpdating = ApiaryXmlState.LoadState();

            int workersInFirstBeehive = afterUpdating
                                        .BeehiveStates.First(st => st.BeehiveNumber == 1)
                                        .WorkerBeesCount;

            Assert.AreEqual(randomValue, workersInFirstBeehive);

            ApiaryXmlState.ClearCache();
        }