public void ShouldGetWorker() { MockedDatabase <Worker> database; WorkerModule module; Worker result; database = new MockedDatabase <Worker>(false, 1, (t) => new Worker() { WorkerID = t }); module = new WorkerModule(NullLogger.Instance, database); result = module.GetWorker(1); Assert.IsNotNull(result); Assert.AreEqual(0, result.WorkerID); }
public void ShouldNotGetWorkerAndLogError() { MockedDatabase <Worker> database; WorkerModule module; MemoryLogger logger; logger = new MemoryLogger(); database = new MockedDatabase <Worker>(true, 1, (t) => new Worker() { WorkerID = t }); module = new WorkerModule(logger, database); Assert.ThrowsException <PIODataException>(() => module.GetWorker(1)); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); }