Hi
The project I am working on has multiple C# classes which use [BsonRepresentation] attributes for their properties (mostly for Enum types in order to write values as strings in mongo).
I am trying to write tests for these classes that ensure that the Bson representation of the class is as expected. I want to do this by serializing the class to Bson and comparing the resultant string/document with a predefined string.
I tried different versions of BsonSerializer.Serialize, BsonDocumentWrapper.Create and <MyClass>.ToBson() but all attempts throw this exception:
An exception of type 'System.NotSupportedException' occurred in MongoDB.Bson.dll but was not handled in user code
Additional information: A serialization options attribute of type BsonRepresentationAttribute cannot be used when the serializer is of type BsonClassMapSerializer.
Any suggestions?
Thanks!