public void ShouldNotGetPlanetsAndLogError() { MockedDatabase <Planet> database; PlanetModule module; MemoryLogger logger; logger = new MemoryLogger(); database = new MockedDatabase <Planet>(true, 3, (t) => new Planet() { PlanetID = t }); module = new PlanetModule(logger, database); Assert.ThrowsException <PIODataException>(() => module.GetPlanets()); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); }
public void ShouldGetPlanets() { MockedDatabase <Planet> database; PlanetModule module; Planet[] results; database = new MockedDatabase <Planet>(false, 3, (t) => new Planet() { PlanetID = t }); module = new PlanetModule(NullLogger.Instance, database); results = module.GetPlanets(); Assert.IsNotNull(results); Assert.AreEqual(3, results.Length); for (int t = 0; t < 3; t++) { Assert.IsNotNull(results[t]); Assert.AreEqual(t, results[t].PlanetID); } }