public void Should_not_serialize_empty_enumerables() { var bsonClassMap = new BsonClassMap <ComplexSubDocument>(); BsonMemberMap bsonMemberMap = bsonClassMap.MapMember(cr => cr.ComplexValueList); var ignoreEmptyEnumerableConvention = new IgnoreEmptyEnumerablesConvention(); ignoreEmptyEnumerableConvention.Apply(bsonMemberMap); var complexSubDocument = new ComplexSubDocument(); complexSubDocument.ComplexValueList.Clear(); Assert.False(bsonMemberMap.ShouldSerialize(complexSubDocument, complexSubDocument.ComplexValueList)); }
public void Should_serialize_non_empty_enumerables() { var bsonClassMap = new BsonClassMap <ComplexSubDocument>(); BsonMemberMap bsonMemberMap = bsonClassMap.MapMember(cr => cr.ComplexValueList); var ignoreEmptyEnumerableConvention = new IgnoreEmptyEnumerablesConvention(); ignoreEmptyEnumerableConvention.Apply(bsonMemberMap); var complexSubDocument = new ComplexSubDocument { ComplexValueList = { new ComplexType(), new ComplexType(), new ComplexType() } }; Assert.True(bsonMemberMap.ShouldSerialize(complexSubDocument, complexSubDocument.ComplexValueList)); }