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(); }
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); }
public void Setup() { fb = new FakeBus(new FakeDriver("FakeFirstName", "FakeLastName", "FakeGender", "FakeLicence"), 100, 50, 2, 1); fp = new FakePassenger("FakeFirstName", "FakeLastName", "FakeGender", "FakeTicketType"); fd = new FakeDriver("FakeFirstName", "FakeLastName", "FakeGender", "FakeLicence"); fp2 = new FakePassenger("FakeFirstName2", "FakeLastName2", "FakeGender", "FakeTicketType"); }
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(); }
private void InitFakeDriver() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); driver.Init(() => { }); }
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(); }
public void SetUp() { stubUrlBuilder = new StubUrlBuilder(); _stubRestrictedResourceDownloader = new SpyRestrictedResourceDownloader(); driver = new FakeDriver(); session = TestSessionBuilder.Build(driver, new SpyRobustWrapper(), new FakeWaiter(), _stubRestrictedResourceDownloader, stubUrlBuilder); }
public static FakeDriver InitFakeDriver() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); driver.Init(() => { }); return(driver); }
public void SetUp() { stubUrlBuilder = new StubUrlBuilder(); _stubRestrictedResourceDownloader = new SpyRestrictedResourceDownloader(); driver = new FakeDriver(); SessionConfiguration = new SessionConfiguration(); browserSession = TestSessionBuilder.Build(SessionConfiguration, driver, new SpyRobustWrapper(), new FakeWaiter(), _stubRestrictedResourceDownloader, stubUrlBuilder); }
public void SetUp() { driver = new FakeDriver(); spyRobustWrapper = new SpyRobustWrapper(); fakeWaiter = new FakeWaiter(); stubUrlBuilder = new StubUrlBuilder(); sessionConfiguration = new SessionConfiguration(); browserSession = TestSessionBuilder.Build(sessionConfiguration, driver, spyRobustWrapper, fakeWaiter, new SpyRestrictedResourceDownloader(), stubUrlBuilder); elementScope = browserSession.FindXPath("."); }
public void SetUp() { driver = new FakeDriver(); SpyTimingStrategy = new SpyTimingStrategy(); fakeWaiter = new FakeWaiter(); stubUrlBuilder = new StubUrlBuilder(); sessionConfiguration = new SessionConfiguration(); browserSession = TestSessionBuilder.Build(sessionConfiguration, driver, SpyTimingStrategy, fakeWaiter, new SpyRestrictedResourceDownloader(), stubUrlBuilder); elementScope = browserSession.FindXPath("."); popupScope = browserSession.FindWindow("popup"); }
public void MultiBarSeriesColors_WrongNumber() { var fake = new FakeDriver(); var colors = new [] { fake.MakeAttribute(Color.Green, Color.Black) }; // user passes 1 color only but asks for 5 bars var ex = Assert.Throws <ArgumentException>(() => new MultiBarSeries(5, 7, 1, colors)); Assert.Equal("Number of colors must match the number of bars (Parameter 'numberOfBarsPerCategory')", ex.Message); }
public void HeightAsBuffer_Is_True_Top_Cannot_Be_Greater_Than_WindowHeight() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); Application.HeightAsBuffer = true; Assert.True(Application.HeightAsBuffer); driver.SetWindowPosition(80, 26); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); Application.Shutdown(); }
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(); }
public void HeightAsBuffer_Is_False_Left_And_Top_Is_Always_Zero() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); Assert.False(Application.HeightAsBuffer); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); driver.SetWindowPosition(5, 5); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); Application.Shutdown(); }
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(); }
public void MultiBarSeriesColors_RightNumber() { var fake = new FakeDriver(); var colors = new [] { fake.MakeAttribute(Color.Green, Color.Black), fake.MakeAttribute(Color.Green, Color.White), fake.MakeAttribute(Color.BrightYellow, Color.White) }; // user passes 3 colors and asks for 3 bars var series = new MultiBarSeries(3, 7, 1, colors); Assert.Equal(series.SubSeries.ElementAt(0).OverrideBarColor, colors[0]); Assert.Equal(series.SubSeries.ElementAt(1).OverrideBarColor, colors[1]); Assert.Equal(series.SubSeries.ElementAt(2).OverrideBarColor, colors[2]); }
public void StatusBar_Contructor_Default() { var sb = new StatusBar(); Assert.Empty(sb.Items); Assert.False(sb.CanFocus); Assert.Equal(Colors.Menu, sb.ColorScheme); Assert.Equal(0, sb.X); Assert.Equal(Dim.Fill(), sb.Width); Assert.Equal(1, sb.Height); Assert.Equal(0, sb.Y); var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); sb = new StatusBar(); driver.SetCursorVisibility(CursorVisibility.Default); driver.GetCursorVisibility(out CursorVisibility cv); Assert.Equal(CursorVisibility.Default, cv); Assert.True(FakeConsole.CursorVisible); Application.Iteration += () => { Assert.Equal(24, sb.Y); driver.SetWindowSize(driver.Cols, 15); Assert.Equal(14, sb.Y); sb.OnEnter(null); driver.GetCursorVisibility(out cv); Assert.Equal(CursorVisibility.Invisible, cv); Assert.False(FakeConsole.CursorVisible); Application.RequestStop(); }; Application.Top.Add(sb); Application.Run(); Application.Shutdown(); }
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(); }
public void HeightAsBuffer_Is_True_Top_Cannot_Be_Greater_Than_BufferHeight_Minus_WindowHeight() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); Application.HeightAsBuffer = true; Assert.True(Application.HeightAsBuffer); driver.SetWindowPosition(80, 26); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); // MockDriver will now be sets to 80x40 driver.SetBufferSize(80, 40); Assert.Equal(80, Application.Driver.Cols); Assert.Equal(40, Application.Driver.Rows); Assert.Equal(80, Console.BufferWidth); Assert.Equal(40, Console.BufferHeight); Assert.Equal(80, Console.WindowWidth); Assert.Equal(25, Console.WindowHeight); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); driver.SetWindowPosition(80, 40); Assert.Equal(0, Console.WindowLeft); Assert.Equal(15, Console.WindowTop); driver.SetWindowSize(80, 20); Assert.Equal(80, Application.Driver.Cols); Assert.Equal(40, Application.Driver.Rows); Assert.Equal(80, Console.BufferWidth); Assert.Equal(40, Console.BufferHeight); Assert.Equal(80, Console.WindowWidth); Assert.Equal(20, Console.WindowHeight); Assert.Equal(0, Console.WindowLeft); Assert.Equal(15, Console.WindowTop); driver.SetWindowPosition(80, 41); Assert.Equal(0, Console.WindowLeft); Assert.Equal(20, Console.WindowTop); Application.Shutdown(); }
public void MultiBarSeriesColors_RightNumber() { var fake = new FakeDriver(); var colors = new [] { fake.MakeAttribute(Color.Green, Color.Black), fake.MakeAttribute(Color.Green, Color.White), fake.MakeAttribute(Color.BrightYellow, Color.White) }; // user passes 3 colors and asks for 3 bars var series = new MultiBarSeries(3, 7, 1, colors); Assert.Equal(series.SubSeries.ElementAt(0).OverrideBarColor, colors[0]); Assert.Equal(series.SubSeries.ElementAt(1).OverrideBarColor, colors[1]); Assert.Equal(series.SubSeries.ElementAt(2).OverrideBarColor, colors[2]); // Shutdown must be called to safely clean up Application if Init has been called Application.Shutdown(); }
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(); }
public void TerminalResized_Simulation() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); var wasTerminalResized = false; Application.Resized = (e) => { wasTerminalResized = true; Assert.Equal(120, e.Cols); Assert.Equal(40, e.Rows); }; Assert.Equal(80, Console.BufferWidth); Assert.Equal(25, Console.BufferHeight); // MockDriver is by default 80x25 Assert.Equal(Console.BufferWidth, driver.Cols); Assert.Equal(Console.BufferHeight, driver.Rows); Assert.False(wasTerminalResized); // MockDriver will now be sets to 120x40 driver.SetBufferSize(120, 40); Assert.Equal(120, Application.Driver.Cols); Assert.Equal(40, Application.Driver.Rows); Assert.True(wasTerminalResized); // MockDriver will still be 120x40 wasTerminalResized = false; Application.HeightAsBuffer = true; driver.SetWindowSize(40, 20); Assert.Equal(120, Application.Driver.Cols); Assert.Equal(40, Application.Driver.Rows); Assert.Equal(120, Console.BufferWidth); Assert.Equal(40, Console.BufferHeight); Assert.Equal(40, Console.WindowWidth); Assert.Equal(20, Console.WindowHeight); Assert.True(wasTerminalResized); Application.Shutdown(); }
public void HeightAsBuffer_Is_True_Left_Cannot_Be_Greater_Than_BufferWidth_Minus_WindowWidth() { var driver = new FakeDriver(); Application.Init(driver, new FakeMainLoop(() => FakeConsole.ReadKey(true))); Application.HeightAsBuffer = true; Assert.True(Application.HeightAsBuffer); driver.SetWindowPosition(81, 25); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); // MockDriver will now be sets to 120x25 driver.SetBufferSize(120, 25); Assert.Equal(120, Application.Driver.Cols); Assert.Equal(25, Application.Driver.Rows); Assert.Equal(120, Console.BufferWidth); Assert.Equal(25, Console.BufferHeight); Assert.Equal(120, Console.WindowWidth); Assert.Equal(25, Console.WindowHeight); driver.SetWindowPosition(121, 25); Assert.Equal(0, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); driver.SetWindowSize(90, 25); Assert.Equal(120, Application.Driver.Cols); Assert.Equal(25, Application.Driver.Rows); Assert.Equal(120, Console.BufferWidth); Assert.Equal(25, Console.BufferHeight); Assert.Equal(90, Console.WindowWidth); Assert.Equal(25, Console.WindowHeight); driver.SetWindowPosition(121, 25); Assert.Equal(30, Console.WindowLeft); Assert.Equal(0, Console.WindowTop); Application.Shutdown(); }
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(); }
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(); }
public void SetUp() { vBus = new Bus(new FakeDriver(), 100, 50, 2, 1); fp = new FakePassenger("dan", "gheesling", "male", "disabled"); fd = new FakeDriver(); }