From 7cba2c9cf56af41238624e1e8b7468c77393b607 Mon Sep 17 00:00:00 2001 From: Thomas Nind Date: Wed, 25 Aug 2021 09:19:46 +0100 Subject: [PATCH] Fixed bug setting ColorScheme on Autocomplete --- Terminal.Gui/Core/Autocomplete.cs | 2 +- UnitTests/AutocompleteTests.cs | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Terminal.Gui/Core/Autocomplete.cs b/Terminal.Gui/Core/Autocomplete.cs index 1874d69b6..3b9660649 100644 --- a/Terminal.Gui/Core/Autocomplete.cs +++ b/Terminal.Gui/Core/Autocomplete.cs @@ -67,7 +67,7 @@ namespace Terminal.Gui { } set { - ColorScheme = value; + colorScheme = value; } } diff --git a/UnitTests/AutocompleteTests.cs b/UnitTests/AutocompleteTests.cs index d64abed83..ac671f5a8 100644 --- a/UnitTests/AutocompleteTests.cs +++ b/UnitTests/AutocompleteTests.cs @@ -25,5 +25,33 @@ namespace UnitTests { Assert.Equal ("Cobble", ac.Suggestions[1]); } + + [Fact] + [AutoInitShutdown] + public void TestSettingColorSchemeOnAutocomplete () + { + var tv = new TextView (); + + // to begin with we should be using the default menu color scheme + Assert.Same (Colors.Menu, tv.Autocomplete.ColorScheme); + + // allocate a new custom scheme + tv.Autocomplete.ColorScheme = new ColorScheme () { + Normal = Application.Driver.MakeAttribute (Color.Black, Color.Blue), + Focus = Application.Driver.MakeAttribute (Color.Black, Color.Cyan), + }; + + // should be seperate instance + Assert.NotSame (Colors.Menu, tv.Autocomplete.ColorScheme); + + // with the values we set on it + Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Normal.Foreground); + Assert.Equal (Color.Blue, tv.Autocomplete.ColorScheme.Normal.Background); + + Assert.Equal (Color.Black, tv.Autocomplete.ColorScheme.Focus.Foreground); + Assert.Equal (Color.Cyan, tv.Autocomplete.ColorScheme.Focus.Background); + + + } } }