Пример #1
0
        public void PublicPropertiesGetSetTest()
        {
            var behavior = new HighlightBehavior();
            
            var expectedBrush = new SolidColorBrush(Colors.Blue);
            behavior.HighlightBrush = expectedBrush;
            Assert.AreSame(expectedBrush, behavior.HighlightBrush);

            var expectedFontWeight = FontWeights.ExtraBold;
            behavior.HighlightFontWeight = expectedFontWeight;
            Assert.AreEqual(expectedFontWeight, behavior.HighlightFontWeight);

            const string expectedHighlightText = "highlight text";
            behavior.HightlightText = expectedHighlightText;
            Assert.AreEqual(expectedHighlightText, behavior.HightlightText);

            const string expectedText = "some text";
            behavior.Text = expectedText;
            Assert.AreEqual(expectedText, behavior.Text);
        }
Пример #2
0
        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);
        }
 protected void OnDestroy()
 {
     GameEvents.Current.OnMakeNextMove           -= Current_OnMakeNextMove;
     GameEvents.Current.OnDetectiveTicketRemoved -= Current_OnDetectiveTicketRemoved;
     HighlightBehavior.Destroy();
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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);
        }
Пример #7
0
        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);
        }