Exemple #1
0
        public void RangeConverter_RoundTrip_Ok()
        {
            var d1 = "val1";
            var d2 = "val2";

            var repr = RangeConverter <DateTime> .Join(d1, d2);

            RangeConverter <DateTime> .Split(repr, out var c1, out var c2).Should().BeTrue();

            c1.Should().Be(d1);
            c2.Should().Be(d2);
        }
        public async Task SetPickerValue_CheckDateRange_SetPickerDate_CheckValue()
        {
            var comp = ctx.RenderComponent <MudDateRangePicker>();
            // select elements needed for the test
            var picker = comp.Instance;

            picker.Text.Should().BeNullOrEmpty();
            picker.DateRange.Should().Be(null);
            await comp.InvokeAsync(() => picker.Text = RangeConverter <DateTime> .Join(new DateTime(2021, 01, 01).ToShortDateString(), new DateTime(2021, 01, 10).ToShortDateString()));

            picker.DateRange.Start.Should().Be(new DateTime(2021, 01, 01));
            picker.DateRange.End.Should().Be(new DateTime(2021, 01, 10));
            await comp.InvokeAsync(() => picker.DateRange = new DateRange(new DateTime(2020, 12, 26), new DateTime(2021, 02, 01)));

            picker.Text.Should().Be(RangeConverter <DateTime> .Join(new DateTime(2020, 12, 26).ToShortDateString(), new DateTime(2021, 02, 01).ToShortDateString()));
        }
        public void SetPickerValue_CheckText()
        {
            var comp = ctx.RenderComponent <MudDateRangePicker>(
                Parameter(nameof(MudDateRangePicker.DateRange), new DateRange(DateTime.Now, DateTime.Now.AddDays(5))));
            // select elements needed for the test
            var picker = comp.Instance;

            var textStart = DateTime.Now.ToIsoDateString();
            var textEnd   = DateTime.Now.AddDays(5).ToIsoDateString();

            picker.Text.Should().Be(RangeConverter <DateTime> .Join(textStart, textEnd));
            var inputs = comp.FindAll("input");

            (inputs[0] as IHtmlInputElement).Value.Should().Be(textStart);
            (inputs[1] as IHtmlInputElement).Value.Should().Be(textEnd);
        }