public void should_be_able_to_serialize_timespan_to_floatseconds()
        {
            var span = new TimeSpan(days: 1, hours: 2, minutes: 3, seconds: 4, milliseconds: 5);
            var truth = new Datum()
                {
                    type = Datum.DatumType.R_NUM,
                    r_num = span.TotalSeconds
                };

            var datum = DatumConvert.SerializeObject(span, new TimeSpanConverter());
            truth.ShouldBeEquivalentTo(datum);
        }
Exemple #2
0
        public void ser_deser_a_datetime()
        {
            var obj = new ADateTime
                {
                    Id = "my_id_value",
                    TheDate = DateTime.Parse("10/30/2013 4:55 PM")
                };

            var truth = new Datum
                {
                    type = Datum.DatumType.R_OBJECT
                };
            truth.r_object.Add(new Datum.AssocPair
                {
                    key = "Id",
                    val = new Datum
                        {
                            type = Datum.DatumType.R_STR,
                            r_str = "my_id_value"
                        }
                });
            truth.r_object.Add(new Datum.AssocPair
                {
                    key = "TheDate",
                    val = new Datum
                        {
                            type = Datum.DatumType.R_OBJECT,
                            r_object =
                                {
                                    new Datum.AssocPair {key = "$reql_type$", val = new Datum {type = Datum.DatumType.R_STR, r_str = "TIME"}},
                                    new Datum.AssocPair {key = "epoch_time", val = new Datum {type = Datum.DatumType.R_NUM, r_num = 1383152100}},
                                    new Datum.AssocPair {key = "timezone", val = new Datum {type = Datum.DatumType.R_STR, r_str = "+00:00"}},
                                }
                        }
                });

            var newtonDatum = DatumConvert.SerializeObject(obj);

            truth.ShouldBeEquivalentTo(newtonDatum);

            var newtonObject = DatumConvert.DeserializeObject<ADateTime>(truth);

            newtonObject.ShouldBeEquivalentTo(obj);
        }