public void ReadRow_AutoMappedNullableDecimal_Success() { using (var importer = Helpers.GetImporter("Doubles.xlsx")) { ExcelSheet sheet = importer.ReadSheet(); sheet.ReadHeading(); // Valid cell value. NullableDecimalValue row1 = sheet.ReadRow <NullableDecimalValue>(); Assert.Equal(2.2345m, row1.Value); // Empty cell value. NullableDecimalValue row2 = sheet.ReadRow <NullableDecimalValue>(); Assert.Null(row2.Value); // Invalid cell value. Assert.Throws <ExcelMappingException>(() => sheet.ReadRow <DecimalValue>()); } }
public void ReadRow_CustomMappedNullableDecimal_Success() { using (var importer = Helpers.GetImporter("Doubles.xlsx")) { importer.Configuration.RegisterClassMap <NullableDecimalValueFallbackMap>(); ExcelSheet sheet = importer.ReadSheet(); sheet.ReadHeading(); // Valid cell value. NullableDecimalValue row1 = sheet.ReadRow <NullableDecimalValue>(); Assert.Equal(2.2345m, row1.Value); // Empty cell value. NullableDecimalValue row2 = sheet.ReadRow <NullableDecimalValue>(); Assert.Equal(-10, row2.Value); // Invalid cell value. NullableDecimalValue row3 = sheet.ReadRow <NullableDecimalValue>(); Assert.Equal(10, row3.Value); } }
public bool Equals(TestObject other) { return(IntValue == other.IntValue && (NullableIntValue == null && other.NullableIntValue == null) || NullableIntValue.Equals(other.NullableIntValue) && DecimalValue == other.DecimalValue && (NullableDecimalValue == null && other.NullableDecimalValue == null) || NullableDecimalValue.Equals(other.NullableDecimalValue) && (StringValue == null && other.StringValue == null) || StringValue.Equals(other.StringValue) && DateValue == other.DateValue && (NullableDateValue == null && other.NullableDateValue == null) || NullableDateValue.Equals(other.NullableDateValue) && TimeSpanValue == other.TimeSpanValue && (NullableDateValue == null && other.NullableDateValue == null) || NullableDateValue.Equals(other.NullableDateValue) && (IntArray == null && other.IntArray == null) || IntArray.SequenceEqual(other.IntArray) && (IntCollection == null && other.IntCollection == null) || IntCollection.SequenceEqual(other.IntCollection) && GuidValue == other.GuidValue && (NullableGuidValue == null && other.NullableGuidValue == null) || NullableGuidValue.Equals(other.NullableGuidValue) ); }