Beispiel #1
0
        public void ShouldNotGetBuildingTypesAndLogError()
        {
            MockedDatabase <BuildingType> database;
            BuildingTypeModule            module;
            MemoryLogger logger;


            logger   = new MemoryLogger();
            database = new MockedDatabase <BuildingType>(true, 3, (t) => new BuildingType()
            {
                BuildingTypeID = (BuildingTypeIDs)t
            });
            module = new BuildingTypeModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.GetBuildingTypes());
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }
Beispiel #2
0
        public void ShouldGetBuildingTypes()
        {
            MockedDatabase <BuildingType> database;
            BuildingTypeModule            module;

            BuildingType[] results;

            database = new MockedDatabase <BuildingType>(false, 3, (t) => new BuildingType()
            {
                BuildingTypeID = (BuildingTypeIDs)t
            });
            module  = new BuildingTypeModule(NullLogger.Instance, database);
            results = module.GetBuildingTypes();
            Assert.IsNotNull(results);
            Assert.AreEqual(3, results.Length);
            for (int t = 0; t < 3; t++)
            {
                Assert.IsNotNull(results[t]);
                Assert.AreEqual((BuildingTypeIDs)t, results[t].BuildingTypeID);
            }
        }