public void Basic() { var testCli = new CliUnitTestConsole(80, 1); ConsoleProvider.Current = testCli; var app = new ConsoleApp(80, 1); app.LayoutRoot.Add(new TextBox()).Fill(); var task = app.Start(); testCli.Input.Enqueue(new ConsoleKeyInfo('a', ConsoleKey.A, false, false, false)); string result = null; app.Stopping.SubscribeForLifetime(() => { result = testCli.Buffer.ToString(); }, app); testCli.Input.Enqueue(new ConsoleKeyInfo('*', ConsoleKey.Escape, false, false, false)); task.Wait(); Assert.AreEqual(80, result.Length); Console.WriteLine(result); }
public void TestBasicFormSubmit() { var testCli = new CliUnitTestConsole(80, 4); ConsoleProvider.Current = testCli; var viewModel = new BasicXmlAppViewModel(); var app = ConsoleApp.FromMvVm(Resources.BasicXmlApp, viewModel); app.Stopping.SubscribeForLifetime(() => { Console.WriteLine("STOPPING"); Console.WriteLine(testCli.Buffer.ToString()); Console.WriteLine("STOPPING"); }, app.LifetimeManager); var task = app.Start(); var timer = app.SetTimeout(() => { Assert.IsTrue(app.FocusManager.FocusedControl is TextBox); testCli.Input.Enqueue("Adam"); testCli.Input.Enqueue(ConsoleKey.Tab); testCli.Input.Enqueue(ConsoleKey.Enter); }, TimeSpan.FromMilliseconds(1)); task.Wait(); Assert.AreEqual(new ConsoleString("Adam"), viewModel.Customer.Name); }
public void TestBasicFormSubmit() { var testCli = new CliUnitTestConsole(80,4); ConsoleProvider.Current = testCli; var viewModel = new BasicXmlAppViewModel(); var app = ConsoleApp.FromMvVm(Resources.BasicXmlApp, viewModel); app.Stopping.SubscribeForLifetime(() => { Console.WriteLine("STOPPING"); Console.WriteLine(testCli.Buffer.ToString()); Console.WriteLine("STOPPING"); }, app.LifetimeManager); var task = app.Start(); var timer = app.SetTimeout(() => { Assert.IsTrue(app.FocusManager.FocusedControl is TextBox); testCli.Input.Enqueue("Adam"); testCli.Input.Enqueue(ConsoleKey.Tab); testCli.Input.Enqueue(ConsoleKey.Enter); }, TimeSpan.FromMilliseconds(1)); task.Wait(); Assert.AreEqual(new ConsoleString("Adam"), viewModel.Name); }
public void TestConsoleWipesOnStopped() { var testCli = new CliUnitTestConsole(80, 4); ConsoleProvider.Current = testCli; var viewModel = new BasicXmlAppViewModel(); var app = ConsoleApp.FromMvVm(Resources.BasicXmlApp, viewModel); bool appDrewProperly = false; bool appWipedAfterStoppedEvent = false; bool appWipedAfterTask = false; app.Stopping.SubscribeForLifetime(() => { appDrewProperly = testCli.Buffer.ToString().Trim().Length > 0; Console.WriteLine("STOPPING"); Console.WriteLine(testCli.Buffer.ToString()); Console.WriteLine("STOPPING"); }, app.LifetimeManager); app.Stopped.SubscribeForLifetime(() => { appWipedAfterStoppedEvent = testCli.Buffer.ToString().Trim().Length == 0; Console.WriteLine("STOPPED"); Console.WriteLine(testCli.Buffer.ToString()); Console.WriteLine("STOPPED"); } , app.LifetimeManager); var task = app.Start(); var timer = app.SetTimeout(() => { testCli.Input.Enqueue("Adam"); testCli.Input.Enqueue(ConsoleKey.Tab); testCli.Input.Enqueue(ConsoleKey.Enter); }, TimeSpan.FromMilliseconds(1)); task.Wait(); appWipedAfterTask = testCli.Buffer.ToString().Trim().Length == 0; Console.WriteLine("END"); Console.WriteLine(testCli.Buffer.ToString()); Console.WriteLine("END"); Assert.IsTrue(appDrewProperly, "Assert app drew properly"); Assert.IsTrue(appWipedAfterStoppedEvent, "Assert app wiped properly during event"); Assert.IsTrue(appWipedAfterTask, "Assert app wiped properly afer task"); }
public void Basic() { var testCli = new CliUnitTestConsole(80, 1); ConsoleProvider.Current = testCli; var app = new ConsoleApp(0, 0, 80, 1); app.LayoutRoot.Add(new TextBox()).Fill(); var task = app.Start(); testCli.InputQueue.Enqueue(new ConsoleKeyInfo('a', ConsoleKey.A, false, false, false)); Thread.Sleep(1000); var result = testCli.Buffer.ToString(); testCli.InputQueue.Enqueue(new ConsoleKeyInfo('*', ConsoleKey.Escape, false, false, false)); task.Wait(); Assert.AreEqual(80, result.Length); Console.WriteLine(result); }
public void Basic() { var testCli = new CliUnitTestConsole(80,1); ConsoleProvider.Current = testCli; var app = new ConsoleApp(0, 0, 80, 1); app.LayoutRoot.Add(new TextBox()).Fill(); var task = app.Start(); testCli.Input.Enqueue(new ConsoleKeyInfo('a', ConsoleKey.A, false, false, false)); string result = null; app.Stopping.SubscribeForLifetime(() => { result = testCli.Buffer.ToString(); }, app.LifetimeManager); testCli.Input.Enqueue(new ConsoleKeyInfo('*', ConsoleKey.Escape, false, false, false)); task.Wait(); Assert.AreEqual(80, result.Length); Console.WriteLine(result); }
public void PumpFailurePreservesStack() { var testCli = new CliUnitTestConsole(80, 4); ConsoleProvider.Current = testCli; ConsoleApp app = new ConsoleApp(); var task = app.Start(); app.InvokeNextCycle(() => { throw new FormatException("Some fake exception"); }); try { task.Wait(); Assert.Fail("An exception should have been thrown"); } catch (AggregateException ex) { Assert.AreEqual(typeof(FormatException), ex.InnerException.GetType()); Assert.AreEqual("Some fake exception", ex.InnerException.Message); } }
public void Init() { console = new CliUnitTestConsole(); ConsoleProvider.Current = console; }