• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ParadoxGameConverters / Fronter.NET / 19413594846

16 Nov 2025 11:15PM UTC coverage: 19.496% (+0.2%) from 19.325%
19413594846

push

github

web-flow
Bump dependencies (#916)

107 of 714 branches covered (14.99%)

Branch coverage included in aggregate %.

9 of 11 new or added lines in 2 files covered. (81.82%)

582 of 2820 relevant lines covered (20.64%)

9.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.9
/Fronter.NET/Models/Configuration/Options/DateSelector.cs
1
using Avalonia.Data;
2
using commonItems;
3
using ReactiveUI;
4
using System;
5
using System.Linq;
6

7
namespace Fronter.Models.Configuration.Options;
8

9
internal sealed class DateSelector : ReactiveObject {
10
        public DateSelector(BufferedReader reader) {
12✔
11
                var parser = new Parser();
6✔
12
                RegisterKeys(parser);
6✔
13
                parser.ParseStream(reader);
6✔
14
        }
6✔
15
        private void RegisterKeys(Parser parser) {
6✔
16
                parser.RegisterKeyword("editable", reader => Editable = string.Equals(reader.GetString(), "true", StringComparison.OrdinalIgnoreCase));
12✔
17
                parser.RegisterKeyword("value", reader => {
12✔
18
                        var valueStr = reader.GetString();
6✔
19
                        if (string.IsNullOrWhiteSpace(valueStr)) {
12✔
20
                                Value = null;
6✔
21
                        } else {
6✔
NEW
22
                                Value = new Date(valueStr);
×
NEW
23
                        }
×
24
                });
12✔
25
                parser.RegisterKeyword("minDate", reader => MinDate = new Date(reader.GetString()).ToDateTimeOffset());
12✔
26
                parser.RegisterKeyword("maxDate", reader => MaxDate = new Date(reader.GetString()).ToDateTimeOffset());
12✔
27
                parser.RegisterKeyword("tooltip", reader => Tooltip = reader.GetString());
12✔
28
                parser.RegisterRegex(CommonRegexes.Catchall, ParserHelpers.IgnoreAndLogItem);
6✔
29
        }
6✔
30

31
        public bool Editable { get; private set; } = true; // editable unless disabled
12✔
32
        public DateTimeOffset MinDate { get; set; } = DateTimeOffset.MinValue;
12✔
33
        public DateTimeOffset MaxDate { get; set; } = DateTimeOffset.MaxValue;
12✔
34

35
        public DateTimeOffset? DateTimeOffsetValue {
36
                get;
3✔
37
                set => this.RaiseAndSetIfChanged(ref field, value);
15✔
38
        }
39

40
        public Date? Value {
41
                get {
2✔
42
                        if (DateTimeOffsetValue is null) {
3✔
43
                                return null;
1✔
44
                        }
45

46
                        var offsetValue = DateTimeOffsetValue.Value;
1✔
47
                        return new Date(offsetValue);
1✔
48
                }
2✔
49
                set {
15✔
50
                        if (value is null) {
22✔
51
                                DateTimeOffsetValue = null;
7✔
52
                        } else {
15✔
53
                                DateTimeOffsetValue = value.Value.ToDateTimeOffset();
8✔
54
                        }
8✔
55
                }
15✔
56
        }
57

58
        public string? TextValue {
59
                get => Value?.ToString();
×
60
                set {
×
61
                        if (string.IsNullOrWhiteSpace(value)) {
×
62
                                DateTimeOffsetValue = null;
×
63
                        } else {
×
64
                                var dateElements = value.Split('.').Where(x => !string.IsNullOrEmpty(x)).ToArray();
×
65
                                if (dateElements.Length >= 3) {
×
66
                                        ValidateYearString(dateElements[0]);
×
67
                                        ValidateMonthString(dateElements[1]);
×
68
                                        ValidateDayString(dateElements[2]);
×
69
                                } else if (dateElements.Length == 2) {
×
70
                                        ValidateYearString(dateElements[0]);
×
71
                                        ValidateMonthString(dateElements[1]);
×
72
                                } else if (dateElements.Length == 1) {
×
73
                                        ValidateYearString(dateElements[0]);
×
74
                                } else {
×
75
                                        throw new DataValidationException($"'{value}' is not a valid date, it should be in the format YYYY.MM.DD.");
×
76
                                }
77

78
                                DateTimeOffsetValue = new Date(value).ToDateTimeOffset();
×
79
                        }
×
80
                        this.RaisePropertyChanged(nameof(TextValue));
×
81
                }
×
82
        }
83

84
        private static void ValidateYearString(string value) {
×
85
                if (!int.TryParse(value, out int _)) {
×
86
                        throw new DataValidationException($"'{value}' is not a valid integer.");
×
87
                }
88
        }
×
89
        private static void ValidateMonthString(string value) {
×
90
                if (!int.TryParse(value, out var month)) {
×
91
                        throw new DataValidationException($"'{value}' is not a valid integer.");
×
92
                }
93
                if (month is < 1 or > 12) {
×
94
                        throw new DataValidationException($"'{value}' is not a valid month, it should be between 1 and 12.");
×
95
                }
96
        }
×
97
        private static void ValidateDayString(string value) {
×
98
                if (!int.TryParse(value, out var day)) {
×
99
                        throw new DataValidationException($"'{value}' is not a valid integer.");
×
100
                }
101
                if (day is < 1 or > 31) {
×
102
                        throw new DataValidationException($"'{value}' is not a valid day, it should be between 1 and 31.");
×
103
                }
104
        }
×
105

106
        public string? Tooltip { get; private set; }
6✔
107

108
        public bool UseDatePicker {
109
                get;
×
110
                set => this.RaiseAndSetIfChanged(ref field, value);
×
111
        } = false;
6✔
112

113
        public void ToggleUseDatePicker() {
×
114
                UseDatePicker = !UseDatePicker;
×
115
        }
×
116
        public void ClearValue() {
×
117
                TextValue = null;
×
118
        }
×
119
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc