public void NativeTypeNullableBoolArray() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_ARRAY, r_array = { new Datum { type = Datum.DatumType.R_BOOL, r_bool = true }, new Datum { type = Datum.DatumType.R_NULL }, new Datum { type = Datum.DatumType.R_BOOL, r_bool = true }, } }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(bool?[])); }
public void NativeTypeBinary() { var dcf = new TestDatumConverterFactory(); var datum = new Datum() { type = Datum.DatumType.R_OBJECT }; datum.r_object.Add(new Datum.AssocPair() { key = "$reql_type$", val = new Datum() { type = Datum.DatumType.R_STR, r_str = "BINARY" } }); datum.r_object.Add(new Datum.AssocPair() { key = "data", val = new Datum() { type = Datum.DatumType.R_STR, r_str = "SGVsbG8sIHdvcmxkIQ==" } }); var nativeType = dcf.GetBestNativeTypeForDatum(datum); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(byte[])); }
public void NativeTypeDateTime() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum(dateTimeOffsetDatum); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(DateTimeOffset)); }
public void NativeTypeNull() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_NULL }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(object)); }
public void NativeTypeBool() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_BOOL, r_bool = false }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(bool)); }
public void NativeTypeDouble() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_NUM, r_num = 5.5 }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(double)); }
public void NativeTypeString() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_STR, r_str = "Woot!" }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(string)); }
public void NativeTypeDateTimeOffsetArray() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_ARRAY, r_array = { dateTimeOffsetDatum, dateTimeOffsetDatum, dateTimeOffsetDatum } }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(DateTimeOffset[])); }
public void NativeTypeDoubleAndIntArray() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum(new Datum() { type = Datum.DatumType.R_ARRAY, r_array = { new Datum { type = Datum.DatumType.R_NUM, r_num = 5.1 }, new Datum { type = Datum.DatumType.R_NUM, r_num = 7 }, } }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(double[])); }
public void NativeTypeHeterogeneousTypeError() { var dcf = new TestDatumConverterFactory(); Action test = () => dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_ARRAY, r_array = { new Datum { type = Datum.DatumType.R_STR, r_str = "5" }, new Datum { type = Datum.DatumType.R_NUM, r_num = 5 }, } }); test.ShouldThrow <RethinkDbException>().WithMessage("Heterogeneous arrays are not currently supported as their types are indistinguishable"); }
public void NativeTypeStringArray() { var dcf = new TestDatumConverterFactory(); var nativeType = dcf.GetBestNativeTypeForDatum( new Datum() { type = Datum.DatumType.R_ARRAY, r_array = { new Datum { type = Datum.DatumType.R_STR, r_str = "Woot" }, new Datum { type = Datum.DatumType.R_NULL }, } }); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(string[])); }
public void NativeTypeNamedValueCollection() { var dcf = new TestDatumConverterFactory(); var datum = new Datum() { type = Datum.DatumType.R_OBJECT, r_object = { new Datum.AssocPair() { key = "key", val = new Datum() { type = Datum.DatumType.R_NUM, r_num = 100 } } } }; var nativeType = dcf.GetBestNativeTypeForDatum(datum); nativeType.Should().NotBeNull(); nativeType.Should().Be(typeof(Dictionary <string, object>)); }