예제 #1
0
        public void Implicit_Assign()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            var attr = new Attribute();

            var value = 42;
            var fg    = new Color();

            fg = Color.Red;

            var bg = new Color();

            bg = Color.Blue;

            // Test converstion to int
            attr = new Attribute(value, fg, bg);
            int value_implicit = (int)attr.Value;

            Assert.Equal(value, value_implicit);

            // Test converstion from int
            attr = value;
            Assert.Equal(value, attr.Value);

            driver.End();
            Application.Shutdown();
        }
예제 #2
0
        public void PageDown_ExcludesHeaders()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });


            var tableView = new TableView()
            {
                Table       = BuildTable(25, 50),
                MultiSelect = true,
                Bounds      = new Rect(0, 0, 10, 5)
            };

            // Header should take up 2 lines
            tableView.Style.ShowHorizontalHeaderOverline  = false;
            tableView.Style.ShowHorizontalHeaderUnderline = true;
            tableView.Style.AlwaysShowHeaders             = false;

            Assert.Equal(0, tableView.RowOffset);

            tableView.ProcessKey(new KeyEvent(Key.PageDown, new KeyModifiers()));

            // window height is 5 rows 2 are header so page down should give 3 new rows
            Assert.Equal(3, tableView.RowOffset);

            // header is no longer visible so page down should give 5 new rows
            tableView.ProcessKey(new KeyEvent(Key.PageDown, new KeyModifiers()));

            Assert.Equal(8, tableView.RowOffset);
        }
예제 #3
0
        public void Get_Gets()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            var value = 42;
            var fg    = new Color();

            fg = Color.Red;

            var bg = new Color();

            bg = Color.Blue;

            var attr = new Attribute(value, fg, bg);

            driver.SetAttribute(attr);

            var ret_attr = Attribute.Get();

            Assert.Equal(value, ret_attr.Value);
            Assert.Equal(fg, ret_attr.Foreground);
            Assert.Equal(bg, ret_attr.Background);

            driver.End();
            Application.Shutdown();
        }
예제 #4
0
        private void InitFakeDriver()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });
        }
예제 #5
0
        public void End_Cleans_Up()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            FakeConsole.ForegroundColor = ConsoleColor.Red;
            Assert.Equal(ConsoleColor.Red, Console.ForegroundColor);

            FakeConsole.BackgroundColor = ConsoleColor.Green;
            Assert.Equal(ConsoleColor.Green, Console.BackgroundColor);
            driver.Move(2, 3);
            Assert.Equal(2, Console.CursorLeft);
            Assert.Equal(3, Console.CursorTop);

            driver.End();
            Assert.Equal(0, Console.CursorLeft);
            Assert.Equal(0, Console.CursorTop);
            Assert.Equal(ConsoleColor.Gray, Console.ForegroundColor);
            Assert.Equal(ConsoleColor.Black, Console.BackgroundColor);

            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }
예제 #6
0
        public static FakeDriver InitFakeDriver()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });
            return(driver);
        }
예제 #7
0
        public void Init_Inits()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            Assert.Equal(80, Console.BufferWidth);
            Assert.Equal(25, Console.BufferHeight);

            // MockDriver is always 80x25
            Assert.Equal(Console.BufferWidth, driver.Cols);
            Assert.Equal(Console.BufferHeight, driver.Rows);
            driver.End();
        }
예제 #8
0
        public void Constuctors_Constuct()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            // Test parameterless constructor
            var attr = new Attribute();

            Assert.Equal(default(int), attr.Value);
            Assert.Equal(default(Color), attr.Foreground);
            Assert.Equal(default(Color), attr.Background);

            // Test value, foreground, background
            var value = 42;
            var fg    = new Color();

            fg = Color.Red;

            var bg = new Color();

            bg = Color.Blue;

            attr = new Attribute(value, fg, bg);

            Assert.Equal(value, attr.Value);
            Assert.Equal(fg, attr.Foreground);
            Assert.Equal(bg, attr.Background);

            // value, foreground, background
            attr = new Attribute(fg, bg);

            Assert.Equal(fg, attr.Foreground);
            Assert.Equal(bg, attr.Background);

            attr = new Attribute(fg);
            Assert.Equal(fg, attr.Foreground);
            Assert.Equal(fg, attr.Background);

            attr = new Attribute(bg);
            Assert.Equal(bg, attr.Foreground);
            Assert.Equal(bg, attr.Background);

            driver.End();
            Application.Shutdown();
        }
예제 #9
0
        public void Init_Inits()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            Assert.Equal(80, Console.BufferWidth);
            Assert.Equal(25, Console.BufferHeight);

            // MockDriver is always 80x25
            Assert.Equal(Console.BufferWidth, driver.Cols);
            Assert.Equal(Console.BufferHeight, driver.Rows);
            driver.End();

            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }
예제 #10
0
        public void SetColors_Changes_Colors()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });
            Assert.Equal(ConsoleColor.Gray, Console.ForegroundColor);
            Assert.Equal(ConsoleColor.Black, Console.BackgroundColor);

            Console.ForegroundColor = ConsoleColor.Red;
            Assert.Equal(ConsoleColor.Red, Console.ForegroundColor);

            Console.BackgroundColor = ConsoleColor.Green;
            Assert.Equal(ConsoleColor.Green, Console.BackgroundColor);

            Console.ResetColor();
            Assert.Equal(ConsoleColor.Gray, Console.ForegroundColor);
            Assert.Equal(ConsoleColor.Black, Console.BackgroundColor);
            driver.End();
        }
예제 #11
0
        public void Make_Creates()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });

            var fg = new Color();

            fg = Color.Red;

            var bg = new Color();

            bg = Color.Blue;

            var attr = Attribute.Make(fg, bg);

            Assert.Equal(fg, attr.Foreground);
            Assert.Equal(bg, attr.Background);

            driver.End();
            Application.Shutdown();
        }
예제 #12
0
        public void SetColors_Changes_Colors()
        {
            var driver = new FakeDriver();

            Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true)));
            driver.Init(() => { });
            Assert.Equal(ConsoleColor.Gray, Console.ForegroundColor);
            Assert.Equal(ConsoleColor.Black, Console.BackgroundColor);

            Console.ForegroundColor = ConsoleColor.Red;
            Assert.Equal(ConsoleColor.Red, Console.ForegroundColor);

            Console.BackgroundColor = ConsoleColor.Green;
            Assert.Equal(ConsoleColor.Green, Console.BackgroundColor);

            Console.ResetColor();
            Assert.Equal(ConsoleColor.Gray, Console.ForegroundColor);
            Assert.Equal(ConsoleColor.Black, Console.BackgroundColor);
            driver.End();

            // Shutdown must be called to safely clean up Application if Init has been called
            Application.Shutdown();
        }