示例#1
0
        public void Retrieve_null_for_nullable_value_when_nullable_TimeSpan(string value)
        {
            var retriever = new TimeSpanValueRetriever();
            var result    = (TimeSpan?)retriever.Retrieve(new KeyValuePair <string, string>(IrrelevantKey, value), IrrelevantType, typeof(TimeSpan?));

            result.Should().Be(null);
        }
示例#2
0
        public void Retrieve_Zero_for_illegal_values(string value)
        {
            var retriever = new TimeSpanValueRetriever();
            var result    = (TimeSpan)retriever.Retrieve(new KeyValuePair <string, string>(IrrelevantKey, value), IrrelevantType, typeof(TimeSpan));

            result.Should().Be(TimeSpan.Zero);
        }
示例#3
0
        public void Retrieve_correct_nullable_value(string value)
        {
            var retriever = new TimeSpanValueRetriever();
            var result    = (TimeSpan?)retriever.Retrieve(new KeyValuePair <string, string>(IrrelevantKey, value), IrrelevantType, typeof(TimeSpan?));

            result.Should().Be(TimeSpan.Parse(value));
        }
示例#4
0
        public void CanRetrieve(Type type, bool expectation)
        {
            var retriever = new TimeSpanValueRetriever();
            var result    = retriever.CanRetrieve(new KeyValuePair <string, string>(IrrelevantKey, IrrelevantKey), IrrelevantType, type);

            result.Should().Be(expectation);
        }
        public void Returns_a_timespan_when_passed_a_parsable_string_representation_of_a_timespan_and_culture_is_fr_FR()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");

            var retriever = new TimeSpanValueRetriever();

            retriever.GetValue("6:12:14:45,3448").Should().Be(System.TimeSpan.Parse("6.12:14:45.3448000"));
        }
        public void Returns_a_timespan_when_passed_a_parsable_string_representation_of_a_timespan()
        {
            var retriever = new TimeSpanValueRetriever();

            retriever.GetValue("20:00:00").Should().Be(System.TimeSpan.Parse("20:00:00"));
            retriever.GetValue("20:00:01").Should().Be(System.TimeSpan.Parse("20:00:01"));
            retriever.GetValue("00:00:00").Should().Be(System.TimeSpan.Parse("00:00:00"));
        }
        public void It_handles_timespans()
        {
            IValueRetriever retriever = new TimeSpanValueRetriever();
            var             empty     = new System.Collections.Generic.KeyValuePair <string, string>();

            retriever.CanRetrieve(empty, null, typeof(System.TimeSpan)).Should().BeTrue();
            retriever.CanRetrieve(empty, null, typeof(System.String)).Should().BeFalse();
            retriever.CanRetrieve(empty, null, typeof(System.Boolean)).Should().BeFalse();
        }
示例#8
0
        public void Retrieve_a_TimeSpan_when_passed_a_TimeSpan_value_if_culture_is_fr_Fr()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR", false);

            var retriever = new TimeSpanValueRetriever();
            var result    = (TimeSpan?)retriever.Retrieve(new KeyValuePair <string, string>(IrrelevantKey, "6:12:14:45,3448"), IrrelevantType, typeof(TimeSpan?));

            result.Should().Be(TimeSpan.Parse("6.12:14:45.3448000"));
        }
示例#9
0
        public void Returns_a_timespan_when_passed_a_parsable_string_representation_of_a_timespan()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", false);

            var retriever = new TimeSpanValueRetriever();

            retriever.GetValue("20:00:00").Should().Be(System.TimeSpan.Parse("20:00:00"));
            retriever.GetValue("20:00:01").Should().Be(System.TimeSpan.Parse("20:00:01"));
            retriever.GetValue("00:00:00").Should().Be(System.TimeSpan.Parse("00:00:00"));
            retriever.GetValue("6:12:14:45.3448").Should().Be(System.TimeSpan.Parse("6.12:14:45.3448000"));
        }