public Task StartBot(ISkypeAdapter skype, ITeamCityClient teamCity, BotParameters botParameters, Dictionary <string, string> moduleParameters, TimeConfig timeConfig) { _working = true; _skype = skype; _teamcity = teamCity; _botParameters = botParameters; _timeConfig = timeConfig; var task = Task.Run(delegate { try { _publishChat = _skype.GetChat(botParameters.PublishChatName); if (_publishChat != null) { Console.WriteLine("publish chat found!"); } else { Console.WriteLine("publish chat NOT found!"); } _skype.OnMessageReceived += OnMessageReceived; _timer = new Timer { Interval = timeConfig.BuildCheckInterval.TotalMilliseconds }; _timer.Elapsed += timer_Elapsed; _timer.AutoReset = false; _timer.Start(); while (_working) { Thread.Sleep(5); } } catch (Exception ex) { Console.WriteLine("top lvl exception : " + ex); } }); buildCheckers = _botParameters.Branches.Select( x => new TeamCityBuildChecker( BuildLocator.WithDimensions(BuildTypeLocator.WithId(_botParameters.BuildConfigId), branch: x), _teamcity, x, _timeConfig)).ToList(); _bot = new HelloBot(moduleParameters, buildCheckers, MailSettingsSectionGroup => SendMessage(MailSettingsSectionGroup, _publishChat)); _bot.OnErrorOccured += BotOnErrorOccured; return(task); }
public void SetUp() { Console.WriteLine("Setup start"); skype = Substitute.For <ISkypeAdapter>(); tc = Substitute.For <ITeamCityClient>(); chat = Substitute.For <IChat>(); skype.GetChat("").ReturnsForAnyArgs(chat); bot = new TeamCityBot.TeamCityBot(); botParameters = new BotParameters { PublishChatName = "test", Branches = new[] { "dev" } }; builds = new FakeBuilds(); tc.Builds.Returns(builds); Console.WriteLine("Setup finish"); }