Beispiel #1
0
        public void ShouldNotGetBotForWorkerAndLogError()
        {
            BotModule    module;
            MemoryLogger logger;
            IDatabase    database;

            logger = new MemoryLogger();

            database = Substitute.For <IDatabase>();
            database.Execute <Bot>(Arg.Any <ISelect>()).Returns((x) => { throw new Exception(); });

            module = new BotModule(logger, database);
            Assert.ThrowsException <PIODataException>(() => module.GetBotForWorker(1));
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Error) && (item.ComponentName == module.ModuleName)));
        }
Beispiel #2
0
        public void ShouldGetBotForWorker()
        {
            BotModule module;
            Bot       result;
            IDatabase database;

            database = Substitute.For <IDatabase>();
            database.Execute <Bot>(Arg.Any <ISelect>()).Returns(new Bot[] { new Bot()
                                                                            {
                                                                                BotID = 1
                                                                            } });

            module = new BotModule(NullLogger.Instance, database);
            result = module.GetBotForWorker(1);
            Assert.IsNotNull(result);
            Assert.AreEqual(1, result.BotID);
        }