ArgsTests.CLI.GridTests.TestGridBasic C# (CSharp) Метод

TestGridBasic() приватный Метод

private TestGridBasic ( ) : void
Результат void
        public void TestGridBasic()
        {
            Grid grid = new Grid();
            MemoryDataSource data = new MemoryDataSource();
            grid.DataSource = data;

            for(int i = 0; i < 5; i++)
            {
                data.Items.Add(new { Id = i+1, StringValue = "Some value here" });
            }

            grid.VisibleColumns.Add(new ColumnViewModel("Id".ToConsoleString()));
            grid.VisibleColumns.Add(new ColumnViewModel("StringValue".ToConsoleString()));

            grid.Width = app.LayoutRoot.Width;
            grid.Height = app.LayoutRoot.Height;

            app.LayoutRoot.Controls.Add(grid);
            Task doneTask = app.Start();
            // give the UI thread a few milliseconds to paint before checking it
            // todo - maybe implement an after paint event on console app
            Thread.Sleep(100);

            // grab the state of the UI to check for the grid
            var consoleState = console.Buffer.ToString();

            // exit the app by simulating an escape key press
            console.Input.Enqueue(new ConsoleKeyInfo(' ', ConsoleKey.Escape,false,  false, false));

            // wait for the app to exit normally
            doneTask.Wait();

            // verify that the console state matches our expected state
            Assert.AreEqual(Resources.BasicGridExpectedOutput.Replace("\r\n", "\n").Replace("\r","\n"), consoleState.Replace("\r\n", "\n").Replace("\r", "\n"));
        }