public void PrintFormattedString_When_OneArgumentIsSpecified() { // Arrange var fixture = new Fixture(); var expectedText = fixture.Create <string>(); var originalConsoleOut = System.Console.Out; // preserve the original stream string formattedStringToBePrinted; using (var writer = new StringWriter()) { System.Console.SetOut(writer); // Act var consoleProvider = new ConsoleProvider(); consoleProvider.WriteLine(expectedText); writer.Flush(); formattedStringToBePrinted = writer.GetStringBuilder().ToString(); } // Assert Assert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText, "\r\n"))); // Clean-up System.Console.SetOut(originalConsoleOut); }
public Analyzer() { LoggingCommand.Initialize(); _serviceProvider = new ServiceProvider(); _consoleProvider = new ConsoleProvider(); _commandProcessor = new CommandProcessor(); _symbolService = new SymbolService(this); _contextService = new ContextService(this); _serviceProvider.AddService <IHost>(this); _serviceProvider.AddService <IConsoleService>(_consoleProvider); _serviceProvider.AddService <ICommandService>(_commandProcessor); _serviceProvider.AddService <ISymbolService>(_symbolService); _serviceProvider.AddService <IContextService>(_contextService); _serviceProvider.AddServiceFactory <SOSLibrary>(() => SOSLibrary.Create(this)); _contextService.ServiceProvider.AddServiceFactory <ClrMDHelper>(() => { ClrRuntime clrRuntime = _contextService.Services.GetService <ClrRuntime>(); return(clrRuntime != null ? new ClrMDHelper(clrRuntime) : null); }); _commandProcessor.AddCommands(new Assembly[] { typeof(Analyzer).Assembly }); _commandProcessor.AddCommands(new Assembly[] { typeof(ClrMDHelper).Assembly }); _commandProcessor.AddCommands(new Assembly[] { typeof(SOSHost).Assembly }); _commandProcessor.AddCommands(typeof(HelpCommand), (services) => new HelpCommand(_commandProcessor, services)); _commandProcessor.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleProvider.Stop)); }
public void PrintFormattedString_When_FormatAndTwoArgumentAreSpecified() { // Arrange var fixture = new Fixture(); var expectedText1 = fixture.Create <string>(); var expectedText2 = fixture.Create <string>(); var originalConsoleOut = System.Console.Out; string formattedStringToBePrinted; using (var writer = new StringWriter()) { System.Console.SetOut(writer); // Act var consoleProvider = new ConsoleProvider(); consoleProvider.Write("{0}{1}", expectedText1, expectedText2); writer.Flush(); formattedStringToBePrinted = writer.GetStringBuilder().ToString(); } // Assert Assert.That(formattedStringToBePrinted, Is.EqualTo(string.Concat(expectedText1, expectedText2))); // Clean-up System.Console.SetOut(originalConsoleOut); }
public override void ChooseOperation() { Bank.ShowMessage(ConsoleProvider.OperationsDebitCard); switch (ConsoleProvider.ReadChooseAction(PossibleCountOfDebitCardActions)) { case (int)DebitCardOperation.TransferMoneyToAccount: string numberAccount = ConsoleProvider.InputStringValue(ConsoleProvider.InputRecepientAccounts); if (numberAccount.Length != 0) { TransferMoneyToAccount(numberAccount, ConsoleProvider.InputIntegerValue()); } else { Bank.ShowMessage(ConsoleProvider.IncorrectInput); } break; case (int)DebitCardOperation.TransferMoneyToCard: TransferMoneyToCard(); break; case (int)DebitCardOperation.SpendMoney: SpendMoney(); break; } }
//private string speak = "https://www.bing.com/translator/api/language/Speak?locale=ko-KR&gender=female&media=audio/mp3&text=예쁜+여자"; //private string translate = "https://www.bing.com/translator/api/Dictionary/Lookup?from=en&to=ko&text=tall%20woman"; // private TextBox _dataBox; // private TextBox translatedBox; // private TextBox _fromBox; // private TextBox _toBox; public Controller(MainWindow window) { _window = window; WindowController.InitWindowController(window); ConsoleProvider.InitConsole(window); Start(); }
public Analyzer() { _serviceProvider = new ServiceProvider(); _consoleProvider = new ConsoleProvider(); Type type = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? typeof(SOSCommandForWindows) : typeof(SOSCommand); _commandProcessor = new CommandProcessor(_serviceProvider, _consoleProvider, new Assembly[] { typeof(Analyzer).Assembly }, new Type[] { type }); }
private static void Main(string[] args) { var consoleProvider = new ConsoleProvider(); var console = consoleProvider.GetInstance(); var file = new File(); var messageReceiver = new TradeMessageReceiver(console, file); messageReceiver.Start(); }
public Router(ApplicationServer applicationServer, ServiceProvider serviceProvider, ConsoleProvider consoleProvider, EnvironmentProvider environmentProvider, ProcessProvider processProvider, SysTrayProvider sysTrayProvider) { _applicationServer = applicationServer; _serviceProvider = serviceProvider; _consoleProvider = consoleProvider; _environmentProvider = environmentProvider; _processProvider = processProvider; _sysTrayProvider = sysTrayProvider; }
private void InitializeBundle() { var utcTimeProvider = new UTCTimeProvider(); var localTimeOffsetProvider = new LocalTimeOffsetProvider(); var uiCultureProvider = new UICultureProvider(); var consoleProvider = new ConsoleProvider(); this.Bundle.AddService(typeof(IUTCTimeProvider), utcTimeProvider); this.Bundle.AddService(typeof(ILocalTimeOffsetProvider), localTimeOffsetProvider); this.Bundle.AddService(typeof(IUICultureProvider), uiCultureProvider); this.Bundle.AddService(typeof(IConsoleProvider), consoleProvider); }
public Analyzer() { _serviceProvider = new ServiceProvider(); _consoleProvider = new ConsoleProvider(); _commandProcessor = new CommandProcessor(); _symbolService = new SymbolService(this); _serviceProvider.AddService <IHost>(this); _serviceProvider.AddService <IConsoleService>(_consoleProvider); _serviceProvider.AddService <ICommandService>(_commandProcessor); _serviceProvider.AddService <ISymbolService>(_symbolService); _commandProcessor.AddCommands(new Assembly[] { typeof(Analyzer).Assembly }); _commandProcessor.AddCommands(typeof(HelpCommand), (services) => new HelpCommand(_commandProcessor, services)); _commandProcessor.AddCommands(typeof(ExitCommand), (services) => new ExitCommand(_consoleProvider.Stop)); }
public void ReturnsCorrectInput() { // Arrange var fixture = new Fixture(); var expectedInput = fixture.Create <string>(); var sr = new StringReader(expectedInput); System.Console.SetIn(sr); // Act var consoleProvider = new ConsoleProvider(); var actualResult = consoleProvider.ReadLine(); // Assert Assert.That(actualResult, Is.EqualTo(expectedInput)); }
public override void TransferMoneyToCard() { Bank.ShowAccounts(); int chooseAccount = ConsoleProvider.ReadChooseAction(Bank.Accounts.Count); if (Bank.Accounts[chooseAccount].Cards.Count == 0) { Bank.ShowMessage(ConsoleProvider.NoneCardOnAccount); return; } Bank.Accounts[chooseAccount].ShowCards(); int chooseCard = ConsoleProvider.ReadChooseAction(Bank.Accounts[chooseAccount].Cards.Count); Card card = Bank.Accounts[chooseAccount].Cards[chooseCard]; int money = ConsoleProvider.InputIntegerValue(); if (money > card.Balance) { Bank.ShowMessage(ConsoleProvider.LackingMoney); } else { if (card == this) { Bank.ShowMessage(ConsoleProvider.IncorrectOperation); return; } card.Balance += money; Balance -= money; Bank.ShowMessage(ConsoleProvider.SuccessfullyOperation); } }
public static void ProcessArguments(string[] args) { if (args.Length >= 1) { var clonePath = args[0]; if (args.Length == 2 && args[1] == "--gui") { // show gui var updaterWindow = new UpdaterWindow(); updaterWindow.ClonePath = clonePath; updaterWindow.ShowDialog(); } else { ConsoleProvider.Attach(); Console.WriteLine("Updating..."); RunUpdate(clonePath); Console.WriteLine("Updating completed."); ConsoleProvider.Detach(); } } }
void DumpData(object Sender, UpdateEventArgs e) { if (!e.argument.Equals("-DumpData", StringComparison.OrdinalIgnoreCase)) { return; } // Dump Procedure StringBuilder DataDump = new StringBuilder(); Diagnostics.FormatDumpData(ref DataDump, "ConsoleProvider", ConsoleProvider.ToString() + Environment.NewLine); Diagnostics.FormatDumpData(ref DataDump, "Console", Console.ToString() + Environment.NewLine); Diagnostics.FormatDumpData(ref DataDump, "ArgBuffer", ArgBuffer); Diagnostics.FormatDumpData(ref DataDump, "ConsoleBuffers", ConsoleBuffers); Diagnostics.FormatDumpData(ref DataDump, "UpdateEvents", UpdateEvents); Diagnostics.FormatDumpData(ref DataDump, "Runtime.UpdateFrequency", Runtime.UpdateFrequency); Diagnostics.FormatDumpData(ref DataDump, "updateSource", e.updateSource); // Save and Notify Runtime.UpdateFrequency = UpdateFrequency.None; Me.CustomData = DataDump.ToString(); Echo($"Data Dumped into Custom Data.{Environment.NewLine}Execution Stopped."); ConsoleBuffers["DataDump"] = $"Data Dumped into CustomData.{Environment.NewLine}Execution Stopped."; }
public Analyzer() { _serviceProvider = new ServiceProvider(); _consoleProvider = new ConsoleProvider(); _commandProcessor = new CommandProcessor(_serviceProvider, _consoleProvider, new Assembly[] { typeof(Analyzer).Assembly }); }
public Analyzer() { _consoleProvider = new ConsoleProvider(); _commandProcessor = new CommandProcessor(new Assembly[] { typeof(Analyzer).Assembly }); _commandProcessor.AddService(_consoleProvider); }
public ConsoleProviderTests() { _provider = new ConsoleProvider(_settingsService); }
// Public Methods (2) /// <summary> /// Sets the logic that returns the value for <see cref="GlobalConsole.Current" />. /// </summary> /// <param name="newProvider">The new provider delegate.</param> public static void SetConsoleProvider(ConsoleProvider newProvider) { _provider = newProvider; }