protected ReadOnlyRepository <string> GetRepoWithData <T>(List <T> data, string name) where T : class, IEntity <string> { var logger = Mock.Of <ILogger>(); var dc = new ReadOnlyDataContext("connstr", test: true, testName: name); data.ForEach(c => dc.Add(c)); dc.SaveChanges(); var repo = new ReadOnlyRepository <string>(dc); return(repo); }
protected Mock <ReadOnlyRepository <string> > GetRepoMock <T>(string name, bool setupIncl = false) where T : class, IEntity <string> { var logger = Mock.Of <ILogger>(); var dc = new ReadOnlyDataContext("connstr", test: true, testName: name); var repoM = new Mock <ReadOnlyRepository <string> >(dc); if (setupIncl) { repoM.Setup(m => m.Include(It.IsAny <IQueryable <T> >(), It.IsAny <Expression <Func <T, object> > >())) .Returns(dc.ISet <T>()) .Verifiable(); } return(repoM); }
public void Install(IWindsorContainer container, IConfigurationStore store) { container.Register(Component.For(typeof(TransactionalCommandHandlerDecorator <,>)) .LifestyleScoped()); container.Install(new CommandBusInstaller()); container.Register(Classes.FromAssemblyContaining <BrandCommandHandler>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Register(Classes.FromAssemblyContaining <BrandDomainService>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Install(new NotifyInstaller()); var autoMapperProfiles = typeof(BrandProfile).Assembly.GetTypes() .Where(x => x.IsSubclassOf(typeof(Profile))) .Select(Activator.CreateInstance) .OfType <Profile>() .ToList(); Mapper.Initialize(cfg => { autoMapperProfiles.ForEach(cfg.AddProfile); }); container.Register(Classes.FromAssemblyContaining <BrandQueryService>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Register(Classes.FromAssemblyContaining <ProductDomainService>().Pick().WithServiceAllInterfaces() .LifestyleScoped()); container.Register(Component.For <IDomainEventHandlerFactory>().ImplementedBy <DomainEventHandlerFactory>().LifestyleScoped()); //register repository components container.Register(Component.For <IContext>().ImplementedBy <DataContext>() .LifestyleScoped()); container.Register(Component.For(typeof(IRepository <>)).ImplementedBy(typeof(Repository <>)) .LifestyleScoped()); container.Register(Component.For <ISeqRepository>().ImplementedBy <SeqRepository>().LifestyleScoped()); container.Register(Component.For <ReadOnlyDataContext>().LifestyleScoped()); container.Register(Component.For(typeof(IReadOnlyRepository <,>)).ImplementedBy(typeof(ReadOnlyRepository <,>)) .LifestyleScoped()); DataContext.ExecuteMigration(); ReadOnlyDataContext.ExecuteMigration(); DomainEventServiceLocator.SetContainer(container); }
public ReadOnlyRepositoryBase(ReadOnlyDataContext readOnlyContext) { _readOnlyContext = readOnlyContext; }
public ReadOnlyArticleRepository(ReadOnlyDataContext readOnlyContext) : base(readOnlyContext) { }
public ReadOnlyDataContext GetReadOnlyDataContext() { return(_readOnlyDataContext ?? (_readOnlyDataContext = new ReadOnlyDataContext())); }
public BuggyController(ReadOnlyDataContext context) { _context = context; }
public ReadOnlyRepository(ReadOnlyDataContext context) { _context = context; _dbSet = _context.Set <TEntity>(); }