public void SerializeAndDeserializeToTheSameObject(decimal originalValue) { Serializer <decimal> serializer = new DecimalSerializer(); byte[] serializedValue = serializer.Serialize(originalValue); decimal deserializedValue = serializer.Deserialize(serializedValue); Assert.Equal(originalValue, deserializedValue); }
/// <inheritdoc/> public override void Serialize(BsonSerializationContext context, BsonSerializationArgs args, Money value) { var writer = context.Writer; if (value == Money.Zero) { writer.WriteNull(); return; } writer.WriteStartDocument(); writer.WriteName(_amountFieldName); _amountSerializer.Serialize(context, args, value.Amount); writer.WriteName(_currencyFieldName); _currencySerializer.Serialize(context, args, value.Currency); writer.WriteEndDocument(); }