예제 #1
0
        public void ShouldUpdateStack()
        {
            MockedDatabase <Stack> database;
            StackModule            module;

            database = new MockedDatabase <Stack>(false, 1, (t) => new Stack()
            {
                StackID = t, BuildingID = 0, ResourceTypeID = 0, Quantity = 5
            });
            module = new StackModule(NullLogger.Instance, database);
            module.UpdateStack(1, 2);
            Assert.AreEqual(1, database.UpdatedCount);
        }
예제 #2
0
        public void ShouldNotUpdateStackAndLogError()
        {
            MockedDatabase <Stack> database;
            StackModule            module;
            MemoryLogger           logger;


            logger   = new MemoryLogger();
            database = new MockedDatabase <Stack>(true, 1, (t) => new Stack()
            {
                StackID = t, BuildingID = 0, ResourceTypeID = 0, Quantity = 5
            });
            module = new StackModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.UpdateStack(0, 10));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }