public void ShouldNotGetAllTasksAndLogError() { MockedDatabase <Task> database; TaskModule module; MemoryLogger logger; logger = new MemoryLogger(); database = new MockedDatabase <Task>(true, 3, (t) => new Task() { TaskID = t }); module = new TaskModule(logger, database); Assert.ThrowsException <PIODataException>(() => module.GetTasks()); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); }
public void ShouldGetAllTasks() { MockedDatabase <Task> database; TaskModule module; Task[] results; database = new MockedDatabase <Task>(false, 3, (t) => new Task() { TaskID = t }); module = new TaskModule(NullLogger.Instance, database); results = module.GetTasks(); Assert.IsNotNull(results); Assert.AreEqual(3, results.Length); for (int t = 0; t < 3; t++) { Assert.IsNotNull(results[t]); Assert.AreEqual(t, results[t].TaskID); } }