Ejemplo n.º 1
0
        public void Be_Creatable()
        {
            var sut = new NZazuDoubleField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);

            sut.Should().NotBeNull();
            sut.Should().BeAssignableTo <INZazuWpfField>();
        }
Ejemplo n.º 2
0
        public void Create_Control_With_ToolTip_Matching_Description()
        {
            var sut = new NZazuDoubleField(new FieldDefinition
            {
                Key         = "key",
                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);
        }
Ejemplo n.º 3
0
        public void Format_TextBox_From_StringValue()
        {
            var sut = new NZazuDoubleField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var control = (TextBox)sut.ValueControl;

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

            sut.SetValue("1.4");
            control.Text.Should().Be("1.4");

            sut.SetValue("");
            control.Text.Should().BeEmpty();
        }
Ejemplo n.º 4
0
        public void Format_StringValue_From_TextBox()
        {
            var sut = new NZazuDoubleField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var control = (TextBox)sut.ValueControl;

            control.Text = "1.4";
            sut.GetValue().Should().Be("1.4");

            control.Text = string.Empty;
            sut.IsValid().Should().BeTrue();
            sut.GetValue().Should().Be("");

            // ReSharper disable once AssignNullToNotNullAttribute
            control.Text = null;
            sut.IsValid().Should().BeTrue();
            sut.GetValue().Should().Be(string.Empty);
        }
Ejemplo n.º 5
0
        public void Format_Value_From_TextBox()
        {
            var sut = new NZazuDoubleField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var control = (TextBox)sut.ValueControl;

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

            control.Text = "1.";
            sut.Value.Should().BeApproximately(1.0, double.Epsilon);
            control.Text.Should().Be("1.");

            // ReSharper disable once AssignNullToNotNullAttribute
            control.Text = null;
            sut.IsValid().Should().BeTrue();
            sut.Value.Should().NotHaveValue();
        }
Ejemplo n.º 6
0
        public void Support_Format()
        {
            var sut = new NZazuDoubleField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);

            sut.Definition.Settings["Format"] = "0.##";
            var control = (TextBox)sut.ValueControl;

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

            sut.Value = 1.0 / 3.0;
            control.Text.Should().Be("0.33");

            sut.Value = 1.4;
            control.Text.Should().Be("1.4");

            sut.Value = null;
            control.Text.Should().BeEmpty();
        }
Ejemplo n.º 7
0
        public void Format_TextBox_From_Value()
        {
            var sut = new NZazuDoubleField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var control = (TextBox)sut.ValueControl;

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

            sut.Value = 1.0 / 3.0;
            control.Text.Should().Be("0.333333333333333");

            sut.Value = 1.4;
            control.Text.Should().Be("1.4");

            sut.Value = -2.34;
            control.Text.Should().Be("-2.34");

            sut.Value = null;
            control.Text.Should().BeEmpty();
        }