예제 #1
0
        public void DeserializeEmptyDateField()
        {
            var serializer = new DateFieldSerializer();

            var field = (DateField)serializer.Deserialize(null);

            Assert.False(field.Value.HasValue);
        }
예제 #2
0
        public void SerializeEmptyDateField()
        {
            var serializer = new DateFieldSerializer();

            var str = serializer.Serialize(new DateField());

            Assert.Null(str);
        }
예제 #3
0
        public void WrongInputToDateField()
        {
            var serializer = new DateFieldSerializer();

            Assert.Throws <ArgumentException>(() => serializer.Serialize(new StringField
            {
                Value = "Exception"
            }));
        }
예제 #4
0
        public void SerializeDateField()
        {
            var serializer = new DateFieldSerializer();

            var str = serializer.Serialize(new DateField
            {
                Value = new DateTime(2001, 1, 5, 16, 0, 0)
            });

            Assert.Equal("2001-01-05", str);
        }
예제 #5
0
        public void DeserializeDateField()
        {
            var serializer = new DateFieldSerializer();
            var date       = new DateTime(2001, 1, 5, 16, 0, 0);
            var str        = "2001-01-05 16:00:00";

            var field = (DateField)serializer.Deserialize(str);

            Assert.NotNull(field);
            Assert.Equal(date, field.Value.Value);
        }