public void can_convert_to_bson_value() { StringValueCustomBsonTypeMapper.Register <TypedStringValue>(); var val = BsonValue.Create(new TypedStringValue("ABC")); Assert.IsInstanceOf <BsonString>(val); }
public void SetUp() { MongoFlatMapper.EnableFlatMapping(true); MongoDbTestConnectionProvider.ReadModelDb.Drop(); var mngr = new IdentityManager(new CounterService(MongoDbTestConnectionProvider.ReadModelDb)); mngr.RegisterIdentitiesFromAssembly(typeof(DocumentDescriptorId).Assembly); MongoFlatIdSerializerHelper.Initialize(mngr); EventStoreIdentityCustomBsonTypeMapper.Register <DocumentDescriptorId>(); EventStoreIdentityCustomBsonTypeMapper.Register <DocumentId>(); StringValueCustomBsonTypeMapper.Register <BlobId>(); StringValueCustomBsonTypeMapper.Register <DocumentHandle>(); StringValueCustomBsonTypeMapper.Register <FileHash>(); _writer = new DocumentWriter(MongoDbTestConnectionProvider.ReadModelDb); var _documentDescriptorCollection = new MongoReaderForProjections <DocumentDescriptorReadModel, DocumentDescriptorId> ( new MongoStorageFactory(MongoDbTestConnectionProvider.ReadModelDb, new RebuildContext(true))); var _documentDeletedCollection = new CollectionWrapper <DocumentDeletedReadModel, String> ( new MongoStorageFactory(MongoDbTestConnectionProvider.ReadModelDb, new RebuildContext(true)), null); _sut = new DocumentProjection(_writer, _documentDescriptorCollection, _documentDeletedCollection); }
public static void AddSerializerForAllStringBasedIdFromAssembly(Assembly assembly) { var asmName = assembly.FullName; _logger.InfoFormat("Scanning assembly {0} for Mongo flat mapping", asmName); foreach (var type in assembly.GetTypes() .Where(t => typeof(IIdentity).IsAssignableFrom(t))) { var fullName = type.FullName; _logger.DebugFormat("Registered IIdentity type {0}", type.FullName); BsonSerializer.RegisterSerializer(type, new EventStoreIdentityBsonSerializer()); EventStoreIdentityCustomBsonTypeMapper.Register(type); } foreach (var type in assembly.GetTypes() .Where(t => typeof(StringValue).IsAssignableFrom(t))) { _logger.DebugFormat("Registered LowercaseStringValue type {0}", type.FullName); BsonSerializer.RegisterSerializer(type, new StringValueBsonSerializer()); StringValueCustomBsonTypeMapper.Register(type); } }