public void ShouldNotCreateBotAndLogError() { BotModule module; MemoryLogger logger; IDatabase database; logger = new MemoryLogger(); database = Substitute.For <IDatabase>(); database.When(x => x.Execute(Arg.Any <IQuery[]>())).Do(x => throw new Exception()); module = new BotModule(logger, database); Assert.ThrowsException <PIODataException>(() => module.CreateBot(1)); Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName))); }
public void ShouldCreateBot() { BotModule module; Bot result; IDatabase database; int counter = 0; database = Substitute.For <IDatabase>(); database.When(x => x.Execute(Arg.Any <IQuery[]>())).Do(x => counter++); module = new BotModule(NullLogger.Instance, database); result = module.CreateBot(1); Assert.IsNotNull(result); Assert.AreEqual(1, result.WorkerID); Assert.AreEqual(1, counter); }