Beispiel #1
0
        public void Format_StringValue_From_TextBox()
        {
            var sut = new NZazuIntegerField(new FieldDefinition {
                Key = "test"
            }, ServiceLocator);
            var textBox = (TextBox)sut.ValueControl;

            textBox.Text = "7";
            sut.GetValue().Should().Be("7");

            textBox.Text = "-12";
            sut.GetValue().Should().Be("-12");

            textBox.Text = "foo bar";
            sut.IsValid().Should().BeFalse();
            sut.GetValue().Should().Be("-12", "WPF binding cannot sync value");

            textBox.Text = "";
            sut.IsValid().Should().BeTrue();
            sut.GetValue().Should().Be("");

            // ReSharper disable once AssignNullToNotNullAttribute
            textBox.Text = null;
            sut.IsValid().Should().BeTrue();
            sut.GetValue().Should().Be(string.Empty);
        }
Beispiel #2
0
        public void Format_TextBox_From_StringValue()
        {
            var sut = new NZazuIntegerField(new FieldDefinition {
                Key = "test"
            }, ServiceLocator);
            var textBox = (TextBox)sut.ValueControl;

            sut.GetValue().Should().BeNullOrEmpty();
            textBox.Text.Should().BeEmpty();

            sut.SetValue("42");
            textBox.Text.Should().Be("42");

            sut.SetValue("-23");
            textBox.Text.Should().Be("-23");

            sut.SetValue(null);
            textBox.Text.Should().Be(string.Empty);
        }