示例#1
0
        public void ShouldDeleteBot()
        {
            BotModule module;
            IDatabase database;
            int       counter = 0;

            database = Substitute.For <IDatabase>();
            database.When(x => x.Execute(Arg.Any <IDelete>())).Do(x => counter++);
            module = new BotModule(NullLogger.Instance, database);
            module.DeleteBot(1);
            Assert.AreEqual(1, counter);
        }
示例#2
0
        public void ShouldNotDeleteBotAndLogError()
        {
            BotModule    module;
            MemoryLogger logger;
            IDatabase    database;


            logger   = new MemoryLogger();
            database = Substitute.For <IDatabase>();
            database.When(x => x.Execute(Arg.Any <IDelete>())).Do(x => throw new Exception());
            module = new BotModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.DeleteBot(1));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }