示例#1
0
        public IntegrationTests()
        {
            _config = new ConfigurationBuilder()
                      .SetBasePath(Directory.GetCurrentDirectory())
                      .AddJsonFile("appsettings.json", optional: false)
                      .Build();

            Log.Logger = new LoggerConfiguration()
                         .ReadFrom.Configuration(_config)
                         .WriteTo.Console()
                         .CreateLogger();

            try
            {
                Log.Information("Serilog enabled for IntegrationTests");
                _server = new TestServer(new WebHostBuilder()
                                         .UseConfiguration(_config)
                                         .UseStartup <IntegrationTestsStartup>()
                                         .UseSerilog());
                _Db      = _server.Host.Services.GetRequiredService <GthxDataContext>();
                _data    = _server.Host.Services.GetService <IGthxData>() as GthxSqlData;
                _client  = _server.Host.Services.GetService <IIrcClient>() as MockIrcClient;
                _botNick = _server.Host.Services.GetService <IBotNick>();
                _gthx    = _server.Host.Services.GetRequiredService <GthxBot>();
            }
            catch (Exception ex)
            {
                Log.Fatal(ex, "TestHost terminated unexpectedly");
                throw;
            }
            finally
            {
                Log.CloseAndFlush();
            }
        }
示例#2
0
 public LurkerModule(IIrcClient client, IGthxData data, IBotNick botNick, ILogger <LurkerModule> logger)
 {
     _client  = client;
     _data    = data;
     _botNick = botNick;
     _logger  = logger;
 }
示例#3
0
        public GthxBot(IEnumerable <IGthxModule> modules, IBotNick botNick, ILogger <GthxBot> logger, IGthxMessageConsumer messageReader)
        {
            _botNick       = botNick;
            _logger        = logger;
            _messageReader = messageReader;

            _logger.LogDebug("GthxBot instantiated");

            _Modules = modules.ToList();

            _botNick.BotNickChangedEvent += BotNick_NickChangedEvent;
            _matchNick = new Regex($@"^{_botNick.BotNick}(:|;|,|-|\s)+(?'message'.+)");

            _messageReader.MessageProducedHandler += HandleIncomingMessage;
        }
示例#4
0
 public ConsoleIrcClient(IBotNick botNick)
 {
     _botNick = botNick;
 }