Exemple #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);
        }
Exemple #2
0
        public void Be_Creatable()
        {
            var sut = new NZazuIntegerField(new FieldDefinition {
                Key = "test"
            }, ServiceLocator);

            sut.Should().NotBeNull();
            sut.Should().BeAssignableTo <INZazuWpfField>();
        }
Exemple #3
0
        public void Create_Control_With_ToolTip_Matching_Description()
        {
            var sut = new NZazuIntegerField(new FieldDefinition
            {
                Key         = "test",
                Hint        = "superhero",
                Description = "check this if you are a registered superhero"
            }, ServiceLocator);

            var textBox = (TextBox)sut.ValueControl;

            textBox.Should().NotBeNull();
            textBox.Text.Should().BeEmpty();
            textBox.ToolTip.Should().Be(sut.Definition.Description);
        }
Exemple #4
0
        public void Format_TextBox_From_Value()
        {
            var sut = new NZazuIntegerField(new FieldDefinition {
                Key = "test"
            }, ServiceLocator);
            var textBox = (TextBox)sut.ValueControl;

            sut.Value.Should().NotHaveValue();
            textBox.Text.Should().BeEmpty();

            sut.Value = 42;
            textBox.Text.Should().Be("42");

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

            sut.Value = null;
            textBox.Text.Should().Be(string.Empty);
        }
Exemple #5
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);
        }
Exemple #6
0
        public void Format_Value_From_TextBox()
        {
            var sut = new NZazuIntegerField(new FieldDefinition {
                Key = "test"
            }, ServiceLocator);
            var textBox = (TextBox)sut.ValueControl;

            sut.Value.Should().NotHaveValue();
            textBox.Text.Should().BeEmpty();

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

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

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

            textBox.Text = "";
            sut.IsValid().Should().BeTrue();
            sut.Value.Should().NotHaveValue();
        }