Exemple #1
0
        public void TryParseTimeOfDayWithValidParameterShouldParseCorrectly()
        {
            TimeOfDay?result;

            Assert.True(EdmValueParser.TryParseTimeOfDay("1:12:5.009000", out result));
            Assert.Equal(new TimeOfDay(1, 12, 5, 9), result);
        }
Exemple #2
0
        public void TryParseTimeOfDayWithValidParameterShouldParseCorrectly()
        {
            TimeOfDay?result;

            EdmValueParser.TryParseTimeOfDay("1:12:5.009000", out result).Should().BeTrue();
            result.Should().Be(new TimeOfDay(1, 12, 5, 9));
        }
Exemple #3
0
        public void TimeOfDayyAsXmlWithValidShouldRoundtripWhenParsed()
        {
            foreach (var time in this.validTime)
            {
                TimeOfDay?parsedTime;
                var       result = EdmValueWriter.TimeOfDayAsXml(time);
                EdmValueParser.TryParseTimeOfDay(result, out parsedTime).Should().BeTrue();

                parsedTime.Should().Be(time);
            }
        }
Exemple #4
0
        public void TimeOfDayyAsXmlWithValidShouldRoundtripWhenParsed()
        {
            foreach (var time in this.validTime)
            {
                TimeOfDay?parsedTime;
                var       result = EdmValueWriter.TimeOfDayAsXml(time);
                Assert.True(EdmValueParser.TryParseTimeOfDay(result, out parsedTime));

                Assert.Equal(time, parsedTime);
            }
        }
        private IEnumerable <EdmError> ComputeErrors()
        {
            TimeOfDay?value;

            if (!EdmValueParser.TryParseTimeOfDay(this.expression.Value, out value))
            {
                return(new EdmError[] { new EdmError(this.Location, EdmErrorCode.InvalidTimeOfDay, Edm.Strings.ValueParser_InvalidTimeOfDay(this.expression.Value)) });
            }
            else
            {
                return(Enumerable.Empty <EdmError>());
            }
        }
Exemple #6
0
        public void ParseTimeOfDayWithInvalidParameterShouldThrowFormatException()
        {
            var invalidTimeOfDays = new[]
            {
                "-1:0:0.0",
                "0:60:59.1",
                "0:59:60.2",
                "0:30:14.10000000",
            };

            foreach (var invalidTimeOfDay in invalidTimeOfDays)
            {
                TimeOfDay?result;
                Assert.False(EdmValueParser.TryParseTimeOfDay(invalidTimeOfDay, out result));
            }
        }
Exemple #7
0
        public void ParseTimeOfDayWithSpaceShouldThrowFormatException()
        {
            TimeOfDay?result;

            Assert.False(EdmValueParser.TryParseTimeOfDay(" ", out result));
        }
Exemple #8
0
        public void ParseTimeOfDayWithEmptyStringShouldThrowFormatException()
        {
            TimeOfDay?result;

            Assert.False(EdmValueParser.TryParseTimeOfDay(string.Empty, out result));
        }
Exemple #9
0
        public void ParseTimeOfDayNullShouldThrowFormatException()
        {
            TimeOfDay?result;

            Assert.False(EdmValueParser.TryParseTimeOfDay(null, out result));
        }
Exemple #10
0
        public void ParseTimeOfDayWithSpaceShouldThrowFormatException()
        {
            TimeOfDay?result;

            EdmValueParser.TryParseTimeOfDay(" ", out result).Should().BeFalse();
        }
Exemple #11
0
        public void ParseTimeOfDayNullShouldThrowFormatException()
        {
            TimeOfDay?result;

            EdmValueParser.TryParseTimeOfDay(null, out result).Should().BeFalse();
        }
        private TimeOfDay ComputeValue()
        {
            TimeOfDay?value;

            return(EdmValueParser.TryParseTimeOfDay(this.expression.Value, out value) ? value.Value : TimeOfDay.MinValue);
        }