コード例 #1
0
            public void SetsTheCorrectFormat(
                string localizedFormat, string expectedFormat)
            {
                var timeFormat = TimeFormat.FromLocalizedTimeFormat(localizedFormat);

                timeFormat.Format.Should().Be(expectedFormat);
            }
コード例 #2
0
            protected SelectTimeParameters CreateParameter(DateTimeOffset start, DateTimeOffset?stop, BeginningOfWeek beginningOfWeek = BeginningOfWeek.Sunday)
            {
                var dateFormat = DateFormat.FromLocalizedDateFormat("MM.DD.YYYY");
                var timeFormat = TimeFormat.FromLocalizedTimeFormat("H:mm");

                return(SelectTimeParameters
                       .CreateFromOrigin(StartTime, beginningOfWeek, start, stop)
                       .WithFormats(dateFormat, timeFormat));
            }
コード例 #3
0
            protected SelectTimeParameters CreateParameter(DateTimeOffset start, DateTimeOffset?stop)
            {
                var dateFormat = DateFormat.FromLocalizedDateFormat("MM.DD.YYYY");
                var timeFormat = TimeFormat.FromLocalizedTimeFormat("H:mm");

                return(SelectTimeParameters
                       .CreateFromBindingString("StartTime", start, stop)
                       .WithFormats(dateFormat, timeFormat));
            }
コード例 #4
0
            public void ThrowsForUnsupportedFormats(string format)
            {
                if (format == "h:mm A" || format == "H:mm")
                {
                    return;
                }

                Action fromFormat = () => TimeFormat.FromLocalizedTimeFormat(format);

                fromFormat.Should().Throw <ArgumentException>();
            }
コード例 #5
0
            public async Task SetsTimeOfDayFormat(string timeFormat)
            {
                var(togglClient, user) = await SetupTestUser();

                var oldPreferences = await togglClient.Preferences.Get();

                var newPreferences = new Preferences(oldPreferences);

                newPreferences.TimeOfDayFormat = TimeFormat.FromLocalizedTimeFormat(timeFormat);
                await togglClient.Preferences.Update(newPreferences);

                var updatedPreferences = await togglClient.Preferences.Get();

                updatedPreferences.TimeOfDayFormat.Should().Be(newPreferences.TimeOfDayFormat);
            }
 public static IEnumerable <object[]> TimeFormats()
 => new List <object[]>
 {
     new object[] { TimeFormat.FromLocalizedTimeFormat("h:mm A") },
     new object[] { TimeFormat.FromLocalizedTimeFormat("H:mm") }
 };
コード例 #7
0
            public void SetsTheCorrectLocalizedFormat(string localizedFormat)
            {
                var timeFormat = TimeFormat.FromLocalizedTimeFormat(localizedFormat);

                timeFormat.Localized.Should().Be(localizedFormat);
            }
コード例 #8
0
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer)
 => TimeFormat.FromLocalizedTimeFormat(reader.Value.ToString());