public void Respect_Height_Setting()
        {
            var expectedHeight = 2 * XceedRichTextField.DefaultHeight;
            var definition     = new FieldDefinition {
                Key = "key"
            };

            definition.Settings.Add("Height", expectedHeight.ToString(CultureInfo.InvariantCulture));

            var field = new XceedRichTextField(definition, ServiceLocator);

            field.ApplySettings(definition);

            var textBox = (RichTextBox)field.ValueControl;

            textBox.MinHeight.Should().Be(expectedHeight);
            textBox.MaxHeight.Should().Be(expectedHeight);

            field = new XceedRichTextField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            expectedHeight = XceedRichTextField.DefaultHeight;
            field.Definition.Settings.Add("Height", "not a number");

            textBox = (RichTextBox)field.ValueControl;
            textBox.MinHeight.Should().Be(expectedHeight);
        }
        public void Set_Vertical_Scrollbar()
        {
            var field = new XceedRichTextField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var textBox = (RichTextBox)field.ValueControl;

            textBox.VerticalScrollBarVisibility.Should().Be(ScrollBarVisibility.Auto);
        }
        public void Be_Creatable()
        {
            var sut = new XceedRichTextField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);

            sut.Should().NotBeNull();
            sut.Should().BeAssignableTo <INZazuWpfField>();
        }
        public void Respect_Format_Setting(string format, Type formatterType)
        {
            var field = new XceedRichTextField(new FieldDefinition {
                Key = "key", Settings = { ["Format"] = format }
            },
                                               ServiceLocator);

            var textBox = (RichTextBox)field.ValueControl;

            textBox.TextFormatter.Should().BeOfType(formatterType);
        }
        public void Override_ContentProperty_to_RichTextBox()
        {
            var field = new XceedRichTextField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);

            field.ContentProperty.Should().Be(RichTextBox.TextProperty);

            var textBox = (RichTextBox)field.ValueControl;

            field.GetValue().Should().BeNullOrEmpty();
            textBox.Text.Should().BeNullOrEmpty();

            field.SetValue("foobar");
            textBox.Text.Should().Contain(field.GetValue());

            textBox.Text = "not foobar";
            textBox.Text.Should().Contain(field.GetValue());
        }
        public void Add_optional_RichTextFormatBar()
        {
            var field = new XceedRichTextField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var textBox   = (RichTextBox)field.ValueControl;
            var formatBar = RichTextBoxFormatBarManager.GetFormatBar(textBox);

            formatBar.Should().BeNull();

            field = new XceedRichTextField(
                new FieldDefinition {
                Key = "key", Settings = { ["ShowFormatBar"] = true.ToString() }
            }, ServiceLocator);

            textBox   = (RichTextBox)field.ValueControl;
            formatBar = RichTextBoxFormatBarManager.GetFormatBar(textBox);
            formatBar.Should().NotBeNull();
        }
        public void Toggle_CallSigns_on_KeyGesture()
        {
            INZazuWpfField gistField = new XceedRichTextField(new FieldDefinition {
                Key = "myGist"
            }, ServiceLocator);

            gistField.GetValue().Should().BeNullOrWhiteSpace();

            var routedEvent = Keyboard.KeyUpEvent;
            var source      = Substitute.For <PresentationSource>();
            var keyGesture  = new KeyGesture(Key.Home);
            var key         = keyGesture.Key;
            var device      = Keyboard.PrimaryDevice;
            var eventArgs   = new KeyEventArgs(device, source, 0, key)
            {
                RoutedEvent = routedEvent
            };

            var textBox = (RichTextBox)gistField.ValueControl;

            textBox.RaiseEvent(eventArgs);
            gistField.GetValue().Should().BeNullOrWhiteSpace("neither from or to has value that could be toggled");
        }