public void MathInputButton_KeyboardProperty() { var mathKeyboardClassThatProcessesKeyPresses = new MathKeyboard(); var mathInputButton = new MathInputButton(); mathInputButton.SetValue(MathInputButton.KeyboardProperty, mathKeyboardClassThatProcessesKeyPresses); Assert.Equal(mathKeyboardClassThatProcessesKeyPresses, mathInputButton.Keyboard); }
public void MathInputButtonsHaveTransparentBackgroundByDefault(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; Assert.Equal(Color.Transparent, mathInputButton.BackgroundColor); }
public void AllMathInputButtonsHaveLatexContent(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; Assert.False(string.IsNullOrEmpty(mathInputButton.Content?.LaTeX)); }
public void MathInputButtonPlaceholderColorsAreOverridableForDoublePlaceholders(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput, PlaceholderActiveColor = Color.Black, PlaceholderRestingColor = Color.LightGray }; Assert.Equal(Color.Black, mathInputButton.PlaceholderActiveColor); Assert.Equal(Color.LightGray, mathInputButton.PlaceholderRestingColor); TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{#FF000000}{😀}", @"\color{#FFD3D3D3}{😐}"); }
public void MathInputButtonPlaceholderColorsAreOverridableForSinglePlaceholder(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput, PlaceholderActiveColor = Color.Red }; Assert.Equal(Color.Red, mathInputButton.PlaceholderActiveColor); Assert.Null(mathInputButton.PlaceholderRestingColor); Assert.Contains(@"\color{#FFFF0000}{😀}", mathInputButton.Content.NotNull().LaTeX.NotNull()); }
public void MathInputButtonPlaceholdersAreSameAsEditorOutputByDefaultForDoublePlaceholders(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; Assert.Null(mathInputButton.PlaceholderActiveColor); Assert.Null(mathInputButton.PlaceholderRestingColor); TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{green}{😀}", @"\color{blue}{😐}"); }
public void MathInputButtonPlaceholdersAreSameAsEditorOutputByDefaultForSinglePlaceholder(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; Assert.Null(mathInputButton.PlaceholderActiveColor); Assert.Null(mathInputButton.PlaceholderRestingColor); Assert.Contains(@"\color{green}{😀}", mathInputButton.Content.NotNull().LaTeX.NotNull()); }
public void MathInputButtonTwoPlaceholdersWithSameNucleusColorsAreOverridable(MathKeyboardInput mathKeyboardInput) { LaTeXSettings.PlaceholderActiveNucleus = LaTeXSettings.PlaceholderRestingNucleus = "😀"; var mathInputButton = new MathInputButton { Input = mathKeyboardInput, PlaceholderActiveColor = Color.Black, PlaceholderRestingColor = Color.LightGray }; Assert.Equal(Color.Black, mathInputButton.PlaceholderActiveColor); Assert.Equal(Color.LightGray, mathInputButton.PlaceholderRestingColor); TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{#FF000000}{😀}", @"\color{#FFD3D3D3}{😀}"); }
public void MathInputButtonTwoPlaceholdersWithSameNucleusColorsSameAsEditorOutput(MathKeyboardInput mathKeyboardInput) { LaTeXSettings.PlaceholderActiveNucleus = LaTeXSettings.PlaceholderRestingNucleus = "■"; var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; Assert.Null(mathInputButton.PlaceholderActiveColor); Assert.Null(mathInputButton.PlaceholderRestingColor); TestTwoButtonDisplayPlaceholders(mathInputButton, @"\color{green}{■}", @"\color{blue}{■}"); }
public void MathInputButtonsHaveBlackTextColorByDefault(MathKeyboardInput mathKeyboardInput) { var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; // At the time of writing this test, phatom = @"{\color{#00FFFFFF}{|}}" (Xamarin.Forms.Color.Transparent = "#00FFFFFF") is used as there is no \phantom command yet. // As soon as \phantom has been implemented, the call .Replace(LatexHelper.phantom, "") can be removed. Assert.DoesNotContain(@"\color", mathInputButton.Content.NotNull().LaTeX.NotNull().Replace(LatexHelper.phantom, "")); Assert.Equal(Color.Black, mathInputButton.TextColor); }
public void MathInputButtonTextColorCanChangeMultipleTimes() { var mathInputButton = new MathInputButton { Input = MathKeyboardInput.Fraction }; Assert.True(mathInputButton.ImageSourceEquals("files/buttons/MathInputButton_Fraction_Black.png")); mathInputButton.TextColor = Color.Blue; Assert.True(mathInputButton.ImageSourceEquals("files/buttons/MathInputButton_Fraction_Blue.png")); mathInputButton.TextColor = Color.Black; Assert.True(mathInputButton.ImageSourceEquals("files/buttons/MathInputButton_Fraction_Black.png")); }
public void SameNucleusPlaceholders_MathInputButtonPlaceholderWithSinglePlaceholderIsActive(MathKeyboardInput mathKeyboardInput) { LaTeXSettings.PlaceholderActiveNucleus = LaTeXSettings.PlaceholderRestingNucleus = "■"; var mathInputButton = new MathInputButton { Input = mathKeyboardInput }; Assert.Null(mathInputButton.PlaceholderActiveColor); Assert.Null(mathInputButton.PlaceholderRestingColor); var latex = mathInputButton.Content.NotNull().LaTeX.NotNull(); Assert.Contains(@"\color{green}{■}", latex); Assert.DoesNotContain(@"\color{blue}", latex); }
public void MathInputButton_Command(MathKeyboardInput mathKeyboardInput) { var mathKeyboardClassThatProcessesKeyPresses = new MathKeyboard(); var mathInputButton = new MathInputButton { Input = mathKeyboardInput, Keyboard = mathKeyboardClassThatProcessesKeyPresses }; mathInputButton.Command.Execute(null); // Simulate a MathInputButton key press Assert.Equal(expectedResult(), mathKeyboardClassThatProcessesKeyPresses.LaTeX); string expectedResult() { var kb = new MathKeyboard(); kb.KeyPress(mathKeyboardInput); return(kb.LaTeX); } }
void TestTwoButtonDisplayPlaceholders(MathInputButton mathInputButton, string expectedColoredActivePlaceholder, string expectedColoredRestingPlaceholder) { var mathInputButtonLatex = mathInputButton.Content.NotNull().LaTeX.NotNull(); Assert.Contains(expectedColoredActivePlaceholder, mathInputButtonLatex); Assert.Contains(expectedColoredRestingPlaceholder, mathInputButtonLatex); var activeNucleusIndex = mathInputButtonLatex.IndexOf(expectedColoredActivePlaceholder); var restingNucleusIndex = mathInputButtonLatex.IndexOf(expectedColoredRestingPlaceholder); if (mathInputButton.Input == MathKeyboardInput.Power || mathInputButton.Input == MathKeyboardInput.Subscript) { Assert.True(restingNucleusIndex < activeNucleusIndex); } else { Assert.True(activeNucleusIndex < restingNucleusIndex); } }