Пример #1
0
        public void ShouldNotInsertStackAndLogError()
        {
            MockedDatabase <Stack> database;
            StackModule            module;
            MemoryLogger           logger;


            logger   = new MemoryLogger();
            database = new MockedDatabase <Stack>(true, 1, (t) => new Stack()
            {
                StackID = t
            });
            module = new StackModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.InsertStack(0, ResourceTypeIDs.Wood, 2));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }
Пример #2
0
        public void ShouldInsertStack()
        {
            MockedDatabase <Stack> database;
            StackModule            module;
            Stack    result;
            DateTime eta;

            database = new MockedDatabase <Stack>(false, 1, (t) => new Stack()
            {
                StackID = t
            });
            module = new StackModule(NullLogger.Instance, database);
            eta    = DateTime.Now;
            result = module.InsertStack(0, ResourceTypeIDs.Wood, 2);
            Assert.IsNotNull(result);
            Assert.AreEqual(0, result.BuildingID);
            Assert.AreEqual(ResourceTypeIDs.Wood, result.ResourceTypeID);
            Assert.AreEqual(2, result.Quantity);
            Assert.AreEqual(1, database.InsertedCount);
        }