public void CreateCommand_OptionWithCommandFailingCtor_ThrowsException() { var factory = new CliCommandFactory(new ServiceCollection().BuildServiceProvider()); // Act Action act = () => factory.CreateCommand <CommandWithErrorCtor, TestOptionForCommand>(_ => { }); // Assert act .Should() .Throw <CliCommandCreationFailedException>(); }
private static void HandleSongFinished(object sender, BassNetPlayer.SongFinishedEventArgs e) { if (mode == PlayMode.Party) { while (ThePlayer.PlayQueue.Count < 10) { CliCommandFactory.Execute(ThePlayer, "/random"); //todo : ewww. this ain't pretty } } if (ThePlayer.PlayQueue.Count > 0) { ConsoleUtils.UOut(ConsoleColor.Black, "Now playing : {0}", ConsoleColor.White, ThePlayer.PlayQueue.Peek().ToString()); } }
private static void EnterMainLoop() { string Argument = ""; bool exitProgram = false; ThePlayer.SongFinished += HandleSongFinished; while (!exitProgram) { string ln = Console.ReadLine(); if (ln.StartsWith("/")) { if (ln.StartsWith("/exit")) //todo : yuck. { exitProgram = true; continue; } CliCommandFactory.Execute(ThePlayer, ln); } else { if (!string.IsNullOrEmpty(ln)) { Subsonic.AddChatMessage(ln); } } //todo : messages should be fetched async so we get more of a live chat idea //todo : i keep seeing the whole message log. this sucks IOrderedEnumerable <ChatMessage> messages = Subsonic.GetChatMessages(LastMsgDate).OrderBy(cm => cm.Date); foreach (var msg in messages) { if (msg.Date >= LastMsgDate) { ConsoleUtils.UOut(ConsoleColor.Cyan, msg.ToString()); } } LastMsgDate = messages.Max(msg => msg.Date); } ThePlayer.Stop(); }