diff --git a/Tests/Perspex.Styling.UnitTests/SelectorTests_Class.cs b/Tests/Perspex.Styling.UnitTests/SelectorTests_Class.cs index 45f51622f8..774b9669dd 100644 --- a/Tests/Perspex.Styling.UnitTests/SelectorTests_Class.cs +++ b/Tests/Perspex.Styling.UnitTests/SelectorTests_Class.cs @@ -15,6 +15,22 @@ namespace Perspex.Styling.UnitTests public class SelectorTests_Class { + [Fact] + public void Class_Selector_Should_Have_Correct_String_Representation() + { + var target = new Selector().Class("foo"); + + Assert.Equal(".foo", target.ToString()); + } + + [Fact] + public void PesudoClass_Selector_Should_Have_Correct_String_Representation() + { + var target = new Selector().Class(":foo"); + + Assert.Equal(":foo", target.ToString()); + } + [Fact] public async Task Class_Matches_Control_With_Class() { diff --git a/src/Perspex.Styling/Styling/Selectors.cs b/src/Perspex.Styling/Styling/Selectors.cs index 3a6024a38a..029207b406 100644 --- a/src/Perspex.Styling/Styling/Selectors.cs +++ b/src/Perspex.Styling/Styling/Selectors.cs @@ -25,7 +25,7 @@ namespace Perspex.Styling Contract.Requires(previous != null); Contract.Requires(name != null); - return new Selector(previous, x => MatchClass(x, name), name); + return new Selector(previous, x => MatchClass(x, name), name[0] == ':' ? name : '.' + name); } public static Selector Descendent(this Selector previous)