public void Format_TextBox_From_StringValue()
        {
            var sut = new NZazuDateField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);
            var datePicker = (DatePicker)sut.ValueControl;

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

            var now = DateTime.Now.Date;

            sut.SetValue(now.ToString(CultureInfo.InvariantCulture));
            datePicker.SelectedDate.Should().Be(now);

            sut.SetValue(string.Empty);
            datePicker.SelectedDate.Should().NotHaveValue();
        }
        public void Consider_DateFormat_in_StringValue()
        {
            var sut = new NZazuDateField(new FieldDefinition {
                Key = "key"
            }, ServiceLocator);

            // DateFormat unspecified
            var date    = DateTime.UtcNow;
            var dateStr = date.ToString(CultureInfo.InvariantCulture);

            sut.SetValue(dateStr);
            sut.Value.Should().BeCloseTo(date, 1000, "parsing truncates millis");

            date     += TimeSpan.FromSeconds(1);
            dateStr   = date.ToString(CultureInfo.InvariantCulture);
            sut.Value = date;
            sut.GetValue().Should().Be(dateStr);

            // now specify DateFormat
            const string dateFormat = "yyyy-MMM-dd";

            sut.DateFormat = dateFormat;

            dateStr = date.ToString(dateFormat, CultureInfo.InvariantCulture);
            sut.GetValue().Should().Be(dateStr);

            date     -= TimeSpan.FromDays(60);
            dateStr   = date.ToString(dateFormat, CultureInfo.InvariantCulture);
            sut.Value = date;
            sut.GetValue().Should().Be(dateStr);

            date   += TimeSpan.FromDays(2);
            date    = date.Date; // truncate time (we only check date --> format)
            dateStr = date.ToString(dateFormat, CultureInfo.InvariantCulture);
            sut.SetValue(dateStr);
            sut.Value.Should().Be(date);
        }