Пример #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);
        }