public void Create_NullableDateTime_ConvertLessThanMinimumValidValueThrows() { // Act IConverter <DateTime?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <DateTime?>(); // Assert Assert.NotNull(converter); DateTime value = _minimumValidDateTimeValue.AddTicks(-1); ExceptionAssert.ThrowsArgumentOutOfRange(() => converter.Convert(value), "input", "Azure Tables cannot " + "store DateTime values before the year 1601. Did you mean to use a nullable DateTime?"); }
public void Create_OtherType_CanConvertNull() { // Act IConverter <Poco, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <Poco>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.Equal(EdmType.String, property.PropertyType); Assert.Equal("null", property.StringValue); }
public void Create_NullableDouble_CanConvertNull() { // Act IConverter <double?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <double?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.Equal(EdmType.Double, property.PropertyType); Assert.False(property.DoubleValue.HasValue); }
public void Create_NullableInt64_CanConvertNull() { // Act IConverter <long?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <long?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.Equal(EdmType.Int64, property.PropertyType); Assert.False(property.Int64Value.HasValue); }
public void Create_EntityProperty_CanConvert() { // Act IConverter <EntityProperty, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <EntityProperty>(); // Assert Assert.NotNull(converter); EntityProperty expected = new EntityProperty(1); EntityProperty property = converter.Convert(expected); Assert.Same(expected, property); }
public void Create_NullableEnum_CanConvertNull() { // Act IConverter <AnEnum?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <AnEnum?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.Equal(EdmType.String, property.PropertyType); Assert.Null(property.StringValue); }
public void Create_NullableGuid_CanConvertNull() { // Act IConverter <Guid?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <Guid?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.AreEqual(EdmType.Guid, property.PropertyType); Assert.False(property.GuidValue.HasValue); }
public void Create_NullableBoolean_CanConvertNull() { // Act IConverter <bool?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <bool?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.Equal(EdmType.Boolean, property.PropertyType); Assert.False(property.BooleanValue.HasValue); }
public void Create_NullableDateTime_CanConvertMinimumValidValue() { // Act IConverter <DateTime?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <DateTime?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(_minimumValidDateTimeValue); Assert.NotNull(property); Assert.Equal(EdmType.DateTime, property.PropertyType); Assert.True(property.DateTime.HasValue); Assert.Equal(_minimumValidDateTimeValue, property.DateTime.Value); }
public void Create_NullableDateTimeOffset_CanConvertNull() { // Act IConverter <DateTimeOffset?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <DateTimeOffset?>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(null); Assert.NotNull(property); Assert.AreEqual(EdmType.DateTime, property.PropertyType); Assert.False(property.DateTimeOffsetValue.HasValue); }
public void Create_Boolean_CanConvert(bool expectedValue) { // Act IConverter <bool, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <bool>(); // Assert Assert.NotNull(converter); EntityProperty property = converter.Convert(expectedValue); Assert.NotNull(property); Assert.Equal(EdmType.Boolean, property.PropertyType); Assert.True(property.BooleanValue.HasValue); Assert.Equal(expectedValue, property.BooleanValue.Value); }
public void Create_NullableEnum_CanConvert() { // Act IConverter <AnEnum?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <AnEnum?>(); // Assert Assert.NotNull(converter); const AnEnum expectedValue = AnEnum.B; EntityProperty property = converter.Convert(expectedValue); Assert.NotNull(property); Assert.Equal(EdmType.String, property.PropertyType); Assert.Equal(expectedValue.ToString(), property.StringValue); }
public void Create_ByteArray_CanConvert() { // Act IConverter <byte[], EntityProperty> converter = TToEntityPropertyConverterFactory.Create <byte[]>(); // Assert Assert.NotNull(converter); byte[] expected = new byte[] { 0x12 }; EntityProperty property = converter.Convert(expected); Assert.NotNull(property); Assert.Equal(EdmType.Binary, property.PropertyType); Assert.Same(expected, property.BinaryValue); }
public void Create_String_CanConvert() { // Act IConverter <string, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <string>(); // Assert Assert.NotNull(converter); const string expected = "abc"; EntityProperty property = converter.Convert(expected); Assert.NotNull(property); Assert.Equal(EdmType.String, property.PropertyType); Assert.Same(expected, property.StringValue); }
public void Create_NullableDateTime_CanConvert() { // Act IConverter <DateTime?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <DateTime?>(); // Assert Assert.NotNull(converter); DateTime? expected = DateTime.Now; EntityProperty property = converter.Convert(expected); Assert.NotNull(property); Assert.Equal(EdmType.DateTime, property.PropertyType); Assert.True(property.DateTime.HasValue); Assert.Equal(expected, property.DateTime.Value); }
public void Create_NullableDouble_CanConvert() { // Act IConverter <double?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <double?>(); // Assert Assert.NotNull(converter); const double expectedValue = 3.14; EntityProperty property = converter.Convert(expectedValue); Assert.NotNull(property); Assert.Equal(EdmType.Double, property.PropertyType); Assert.True(property.DoubleValue.HasValue); Assert.Equal(expectedValue, property.DoubleValue.Value); }
public void Create_NullableInt64_CanConvert() { // Act IConverter <long?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <long?>(); // Assert Assert.NotNull(converter); const long expectedValue = 123; EntityProperty property = converter.Convert(expectedValue); Assert.NotNull(property); Assert.Equal(EdmType.Int64, property.PropertyType); Assert.True(property.Int64Value.HasValue); Assert.Equal(expectedValue, property.Int64Value.Value); }
public void Create_Int32_CanConvert() { // Act IConverter <int, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <int>(); // Assert Assert.NotNull(converter); const int expectedValue = 123; EntityProperty property = converter.Convert(expectedValue); Assert.NotNull(property); Assert.Equal(EdmType.Int32, property.PropertyType); Assert.True(property.Int32Value.HasValue); Assert.Equal(expectedValue, property.Int32Value.Value); }
public void Create_NullableGuid_CanConvert() { // Act IConverter <Guid?, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <Guid?>(); // Assert Assert.NotNull(converter); Guid expectedValue = Guid.NewGuid(); EntityProperty property = converter.Convert(expectedValue); Assert.NotNull(property); Assert.Equal(EdmType.Guid, property.PropertyType); Assert.True(property.GuidValue.HasValue); Assert.Equal(expectedValue, property.GuidValue.Value); }
public void Create_DateTimeOffset_CanConvert() { // Act IConverter <DateTimeOffset, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <DateTimeOffset>(); // Assert Assert.NotNull(converter); DateTimeOffset expected = DateTimeOffset.UtcNow; EntityProperty property = converter.Convert(expected); Assert.NotNull(property); Assert.AreEqual(EdmType.DateTime, property.PropertyType); Assert.True(property.DateTimeOffsetValue.HasValue); Assert.AreEqual(expected, property.DateTimeOffsetValue.Value); }
public void Create_OtherType_CanConvert() { // Act IConverter <Poco, EntityProperty> converter = TToEntityPropertyConverterFactory.Create <Poco>(); // Assert Assert.NotNull(converter); Poco original = new Poco { Value = "abc" }; EntityProperty property = converter.Convert(original); Assert.NotNull(property); Assert.Equal(EdmType.String, property.PropertyType); string expected = JsonConvert.SerializeObject(original, Formatting.Indented); Assert.Equal(expected, property.StringValue); }