//register generators public virtual void RegisterEntities(GeneratorSetup setup, SpecsDbContext dbContext) { IMongoDatabase _database = dbContext.SignalBounces.Database; setup.RegisterEntity <SignalDispatch <ObjectId> >() .SetGenerator(GenerateDispatches) .SetPersistentStorage(new MongoDbPersistentStorage(_database, dbContext.SignalDispatches.CollectionNamespace.CollectionName)); }
protected virtual void CreateIndexes(ISpecs instance) { var connectionSettings = instance.Mocker.GetServiceInstance <MongoDbConnectionSettings>(); var context = new SpecsDbContext(connectionSettings); var indexCreator = new SpecsDbInitializer(context); indexCreator.CreateAllIndexes(historyExpirationTime: null); }
private InMemoryStorage SetupGenerator(SpecsDbContext dbContext) { var ammounts = new Dictionary <Type, long> { [typeof(SignalDispatch <ObjectId>)] = 1000, }; return(new GeneratorRunner().Generate( dbContext: dbContext, generatorData: new DispatchesData(), useMemoryStorage: true, ammounts: ammounts)); }
private InMemoryStorage SetupGenerator(SpecsDbContext dbContext) { var ammounts = new Dictionary <Type, long> { [typeof(SubscriberWithMissingData)] = 5000000, [typeof(SpecsDeliveryTypeSettings)] = 10000000, [typeof(SubscriberTopicSettings <ObjectId>)] = 40000000 }; return(new GeneratorRunner().Generate( dbContext: dbContext, generatorData: new SubscribersEmbeddedData(), useMemoryStorage: false, ammounts: ammounts)); }
//methods public override void RegisterEntities(GeneratorSetup setup, SpecsDbContext dbContext) { IMongoDatabase _database = dbContext.SignalBounces.Database; setup.RegisterEntity <SubscriberWithMissingData>() .SetGenerator(GenerateSubscriber); setup.RegisterEntity <SpecsDeliveryTypeSettings>() .SetMultiGenerator <SubscriberWithMissingData>(GenerateDeliveryTypes) .SetPersistentStorage(new MongoDbPersistentStorage(_database, dbContext.SubscriberDeliveryTypeSettings.CollectionNamespace.CollectionName)); setup.RegisterEntity <SubscriberTopicSettings <ObjectId> >() .SetMultiGenerator <SubscriberCategorySettings <ObjectId>, SubscriberWithMissingData>(GenerateTopics) .SetPersistentStorage(new MongoDbPersistentStorage(_database, dbContext.SubscriberTopicSettings.CollectionNamespace.CollectionName)); }
//generate entry point public InMemoryStorage Generate(SpecsDbContext dbContext, IGeneratorData generatorData, bool useMemoryStorage, Dictionary <Type, long> ammounts) { var setup = new GeneratorSetup(); generatorData.RegisterEntities(setup, dbContext); SetDataAmounts(setup, ammounts); InMemoryStorage storage = useMemoryStorage ? SetMemoryStorage(setup, ammounts) : null; setup.ProgressChanged += PrintProgress; setup.Generate(); return(storage); }
//methods public override void SpecInit(ISpecs instance) { if (_isInitialized) { return; } _isInitialized = true; SpecsDbContext dbContext = instance.Mocker.GetServiceInstance <SpecsDbContext>(); IMongoDatabase db = dbContext.SubscriberDeliveryTypeSettings.Database; db.DropCollection(dbContext.SubscriberDeliveryTypeSettings.CollectionNamespace.CollectionName); db.DropCollection(dbContext.SubscriberCategorySettings.CollectionNamespace.CollectionName); db.DropCollection(dbContext.SubscriberTopicSettings.CollectionNamespace.CollectionName); db.DropCollection(dbContext.SignalDispatches.CollectionNamespace.CollectionName); db.DropCollection(dbContext.SignalEvents.CollectionNamespace.CollectionName); }
//methods public override void SpecInit(ISpecs instance) { if (!_serializerConfigured) { SpecsDbContext.ApplyGlobalSerializationSettings(); _serializerConfigured = true; } var connection = new MongoDbConnectionSettings { DatabaseName = "NotificationsSpecs", Host = "localhost", Port = 27017 }; AutoMockedContainer autoMockContainer = instance.Mocker.GetContainer(); autoMockContainer.Configure(cfg => { cfg.For <MongoDbConnectionSettings>().Use(connection); cfg.For <SpecsDbContext>().Use <SpecsDbContext>(); cfg.For <ICollectionFactory>().Use <SpecsDbContext>(); }); }