public void PaymentPaidOn_ShouldNotBeSerialized_WhenNull() { var payment = new Payment { PaidOn = null }; var doc = payment.ToBsonDocument(); Assert.False(doc.Contains("PaidOn")); }
public void PaymentPersonId_ShouldBeSerializedAsBsonIbjectId() { var payment = new Payment { PersonId = DataContext.NewObjectId() }; var document = payment.ToBsonDocument(); var serialized = document["PersonId"]; Assert.True(serialized.IsObjectId, "PersonId is not serialized as BsonObjectId"); }
public void PaymentAmount_ShouldBeSerializedAsNumericType() { var payment = new Payment { Amount = 100.5m }; var document = payment.ToBsonDocument(); var amountDeserialized = document["Amount"]; Assert.True(amountDeserialized.IsDouble, "Payment amount serialized as non-numeric"); }
public void PaymentPaidOn_MustBeSerializedAsNakedDate() { var payment = new Payment { PaidOn = DateTime.Now }; Assert.Throws<BsonSerializationException>(() => payment.ToBsonDocument()); }