Beispiel #1
0
        public void RepeatedValue()
        {
            var row = new InsertRow {
                { "numbers", new[] { 1, 2 } }
            };
            var rowData = row.ToRowsData();

            Assert.Equal(new object[] { 1, 2 }, rowData.Json["numbers"]);
        }
Beispiel #2
0
        public void DateTimeFormatting()
        {
            var row = new InsertRow
            {
                { "field", new DateTime(2000, 1, 1, 5, 0, 0, DateTimeKind.Utc) },
            };
            var rowData = row.ToRowsData();

            Assert.Equal("2000-01-01 05:00:00Z", rowData.Json["field"]);
        }
Beispiel #3
0
        public void SupportedValueTypes_Passthrough(Type type)
        {
            object value = Activator.CreateInstance(type);
            var    row   = new InsertRow {
                { "field", value }
            };
            var rowData = row.ToRowsData();

            Assert.Equal(value, rowData.Json["field"]);
        }
Beispiel #4
0
        public void DateTimeOffsetFormatting()
        {
            var row = new InsertRow
            {
                // 3am UTC
                { "field", new DateTimeOffset(2000, 1, 1, 5, 0, 0, TimeSpan.FromHours(2)) },
            };
            var rowData = row.ToRowsData();

            Assert.Equal("2000-01-01 03:00:00Z", rowData.Json["field"]);
        }
Beispiel #5
0
        public void NestedRecordFormatting()
        {
            var nested = new InsertRow {
                { "inner", "value" }
            };
            var outer = new InsertRow {
                { "outer", nested }
            };
            var rowData = outer.ToRowsData();
            var obj     = (IDictionary <string, object>)rowData.Json["outer"];

            Assert.Equal("value", obj["inner"]);
        }
Beispiel #6
0
        public void SimpleSuccess()
        {
            var row = new InsertRow
            {
                { "field1", "value1" },
                { "field2", null }
            };

            Assert.Equal("value1", row["field1"]);
            row["field3"] = 2;
            var rowData = row.ToRowsData();

            Assert.Equal("value1", rowData.Json["field1"]);
            Assert.Null(rowData.Json["field2"]);
            Assert.Equal(2, rowData.Json["field3"]);
        }