Esempio n. 1
0
        public void Serialize_String_Exception()
        {
            // arrange
            var timeSpanType = new TimeSpanType();

            // act
            Action a = () => timeSpanType.Serialize("bad");

            // assert
            Assert.Throws <ScalarSerializationException>(a);
        }
Esempio n. 2
0
        public void Serialize_Null()
        {
            // arrange
            var timeSpanType = new TimeSpanType();

            // act
            object serializedValue = timeSpanType.Serialize(null);

            // assert
            Assert.Null(serializedValue);
        }
Esempio n. 3
0
        public void Serialize_TimeSpan_Min(TimeSpanFormat format, string expectedValue)
        {
            // arrange
            var      timeSpanType = new TimeSpanType(format);
            TimeSpan timeSpan     = TimeSpan.MinValue;

            // act
            string serializedValue = (string)timeSpanType.Serialize(timeSpan);

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }
Esempio n. 4
0
        public void Serialize_TimeSpan_DefaultFormat()
        {
            // arrange
            var    timeSpanType  = new TimeSpanType();
            var    timeSpan      = TimeSpan.FromMinutes(5);
            string expectedValue = "PT5M";

            // act
            string serializedValue = (string)timeSpanType.Serialize(timeSpan);

            // assert
            Assert.Equal(expectedValue, serializedValue);
        }