public void WhenHighlightTextIsSet_AssociatedTextBlockIsHighlighted() { var behavior = new HighlightBehavior(); var textBlock = new TextBlock(); behavior.Attach(textBlock); behavior.HightlightText = "test"; var foregroundBrush = new SolidColorBrush(Colors.Yellow); behavior.HighlightBrush = new SolidColorBrush(Colors.Blue); behavior.Foreground = foregroundBrush; behavior.HighlightFontWeight = FontWeights.ExtraBold; textBlock.Text = "some TEST text for HighlightBehavior tests"; behavior.Text = textBlock.Text; Assert.AreEqual(5, textBlock.Inlines.Count); Assert.AreEqual("some ", ((Run) textBlock.Inlines[0]).Text); Assert.AreEqual(foregroundBrush.Color, ((SolidColorBrush)(textBlock.Inlines[0].Foreground)).Color); Assert.AreEqual(textBlock.FontWeight, textBlock.Inlines[0].FontWeight); Assert.AreEqual("TEST", ((Run)textBlock.Inlines[1]).Text); Assert.AreEqual(behavior.HighlightBrush, textBlock.Inlines[1].Foreground); Assert.AreEqual(behavior.HighlightFontWeight, textBlock.Inlines[1].FontWeight); Assert.AreEqual(" text for HighlightBehavior ", ((Run)textBlock.Inlines[2]).Text); Assert.AreEqual(foregroundBrush.Color, ((SolidColorBrush)(textBlock.Inlines[2].Foreground)).Color); Assert.AreEqual(textBlock.FontWeight, textBlock.Inlines[2].FontWeight); Assert.AreEqual("test", ((Run)textBlock.Inlines[3]).Text); Assert.AreEqual(behavior.HighlightBrush, textBlock.Inlines[3].Foreground); Assert.AreEqual(behavior.HighlightFontWeight, textBlock.Inlines[3].FontWeight); Assert.AreEqual("s", ((Run)textBlock.Inlines[4]).Text); Assert.AreEqual(foregroundBrush.Color, ((SolidColorBrush)(textBlock.Inlines[4].Foreground)).Color); Assert.AreEqual(textBlock.FontWeight, textBlock.Inlines[4].FontWeight); }
public void WhenHighlightTextIsNotSet_AssociatedTextBlockIsNotHighlighted() { var behavior = new HighlightBehavior(); var textBlock = new TextBlock(); behavior.Attach(textBlock); behavior.HighlightBrush = new SolidColorBrush(Colors.Blue); var foregroundBrush = new SolidColorBrush(Colors.Green); behavior.Foreground = foregroundBrush; behavior.HighlightFontWeight = FontWeights.ExtraBold; textBlock.Text = "some TEST text for HighlightBehavior tests"; behavior.Text = textBlock.Text; Assert.AreEqual(1, textBlock.Inlines.Count); Assert.AreEqual(textBlock.Text, ((Run)textBlock.Inlines[0]).Text); Assert.AreEqual(foregroundBrush.Color, ((SolidColorBrush)(textBlock.Inlines[0].Foreground)).Color); Assert.AreEqual(textBlock.FontWeight, textBlock.Inlines[0].FontWeight); }
public void BlockedContent() { // assert var behavior = new HighlightBehavior(); var textBlock = new TextBlock(); behavior.Attach(textBlock); behavior.ColumnName = "TextFieldData"; var list = new HashSet<string> { "TextFieldData" }; // act behavior.MultiCrAccessDeniedList = list; // arrange Assert.AreEqual(Constants.BlockedContent, ((Run)textBlock.Inlines[0]).Text); }
public void WhenFalseConditionIsSet_AssociatedTextBlockIsNotHighlighted() { // Arrange var behavior = new HighlightBehavior(); var textBlock = new TextBlock(); behavior.Attach(textBlock); var foregroundBrush = new SolidColorBrush(Colors.Yellow); behavior.HighlightBrush = new SolidColorBrush(Colors.Blue); behavior.Foreground = foregroundBrush; behavior.HighlightFontWeight = FontWeights.ExtraBold; behavior.UseCondition = true; textBlock.Text = "some TEST text for HighlightBehavior tests"; behavior.Text = textBlock.Text; // Act (Keep setting properties in same order as in application) behavior.HightlightText = "test"; behavior.Condition = false; // Assert Assert.AreEqual(1, textBlock.Inlines.Count); Assert.AreEqual(textBlock.Text, ((Run)textBlock.Inlines[0]).Text); }
public void WhenAssociatedTextBlockDoesNotContainHighlightedText_TextIsNotHighlighted() { var behavior = new HighlightBehavior(); var textBlock = new TextBlock(); behavior.Attach(textBlock); behavior.HightlightText = "abc"; behavior.HighlightBrush = new SolidColorBrush(Colors.Blue); behavior.HighlightFontWeight = FontWeights.ExtraBold; textBlock.Text = "some TEST text for HighlightBehavior tests"; behavior.Text = textBlock.Text; Assert.AreEqual(1, textBlock.Inlines.Count); Assert.AreEqual(textBlock.Text, ((Run)textBlock.Inlines[0]).Text); Assert.AreEqual(textBlock.Foreground, textBlock.Inlines[0].Foreground); Assert.AreEqual(textBlock.FontWeight, textBlock.Inlines[0].FontWeight); }