//methods public override void SpecInit(INeedDbContext instance) { if (_isInitialized) { return; } ISenderDbContextFactory factory = instance.Mocker.GetServiceInstance <ISenderDbContextFactory>(); factory.InitializeDatabase(); _isInitialized = true; }
private static void InitDatabase(IContainer container) { bool dbExists = false; ISenderDbContextFactory contextFactory = container.Resolve <ISenderDbContextFactory>(); using (SenderDbContext context = contextFactory.GetDbContext()) { var creator = (SqlServerDatabaseCreator)context.Database.GetService <IDatabaseCreator>(); dbExists = creator.Exists(); } if (dbExists) { return; } contextFactory.InitializeDatabase(); var deliveryTypeQueries = container.Resolve <ISubscriberDeliveryTypeSettingsQueries <SubscriberDeliveryTypeSettingsLong, long> >(); deliveryTypeQueries.Insert(new List <SubscriberDeliveryTypeSettingsLong> { new SubscriberDeliveryTypeSettingsLong { SubscriberId = 1, DeliveryType = (int)Model.DeliveryTypes.Email, Address = "*****@*****.**", IsEnabled = true } }).Wait(); var categoryQueries = container.Resolve <ISubscriberCategorySettingsQueries <SubscriberCategorySettings <long>, long> >(); categoryQueries.Insert(new List <SubscriberCategorySettings <long> > { new SubscriberCategorySettings <long> { SubscriberId = 1, DeliveryType = (int)Model.DeliveryTypes.Email, CategoryId = (int)CategoryTypes.CustomerGreetings, IsEnabled = true } }).Wait(); }