Exemplo n.º 1
0
        public void ShouldNotGetBuildingsAndLogError()
        {
            MockedDatabase <Building> database;
            BuildingModule            module;
            MemoryLogger logger;


            logger   = new MemoryLogger();
            database = new MockedDatabase <Building>(true, 3, (t) => new Building()
            {
                BuildingID = t
            });
            module = new BuildingModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.GetBuildings(1));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }
Exemplo n.º 2
0
        public void ShouldGetBuildings()
        {
            MockedDatabase <Building> database;
            BuildingModule            module;

            Building[] results;

            database = new MockedDatabase <Building>(false, 3, (t) => new Building()
            {
                BuildingID = t
            });
            module  = new BuildingModule(NullLogger.Instance, database);
            results = module.GetBuildings(1);
            Assert.IsNotNull(results);
            Assert.AreEqual(3, results.Length);
            for (int t = 0; t < 3; t++)
            {
                Assert.IsNotNull(results[t]);
                Assert.AreEqual(t, results[t].BuildingID);
            }
        }