Beispiel #1
0
 public DocumentsRepositoryTests()
 {
     dbConfiguration     = new DatabaseConfiguration();
     session             = dbConfiguration.GetSession();
     documentsRepository = new NHibernateUniversalRepository <XXX_R55_Documents>(session);
     fakeDocument        = CreateFakeDocument();
 }
 //todo rozbic na osobne klasy dla osobnych encji
 public NHibernateUniversalRepositoryTests()
 {
     dbConfiguration = new DatabaseConfiguration();
     session         = dbConfiguration.GetSession();
     nHibernateUniversalRepositoryQuotation  = new NHibernateUniversalRepository <XXX_R55_Quotations>(session);
     nHibernateUniversalRepositoryPriceLists = new NHibernateUniversalRepository <XXX_R55_PriceLists>(session);
     nHibernateUniversalRepositoryUnits      = new NHibernateUniversalRepository <UnitsDb>(session);
 }
Beispiel #3
0
 public QuotationsCommandHandlerTests()
 {
     dbConfiguration = new DatabaseConfiguration();
     _session        = dbConfiguration.GetSession();
     _nhibernateUniversalRepository           = new NHibernateUniversalRepository <XXX_R55_Documents>(_session);
     _nhibernateQuotationsUniversalRepository = new NHibernateUniversalRepository <XXX_R55_Quotations>(_session);
     _diskDocumentsHelper      = new DiskDocumentsHelper();
     _dbDocumentsHelper        = new DbDocumentsHelper(_nhibernateUniversalRepository, new DocumentToDocumentDbMapper());
     _documentsDomainService   = new DocumentsDomainService(_dbDocumentsHelper, _diskDocumentsHelper);
     _quotationsDomainService  = new QuotationDomainService(_nhibernateQuotationsUniversalRepository, _nhibernateUniversalRepository, new QuotationToQuotationDbMapper());
     _quotationsCommandHandler = new QuotationsCommandHandler(_quotationsDomainService, _documentsDomainService);
 }
Beispiel #4
0
 public UnitsRepositoryTests()
 {
     dbConfiguration = new DatabaseConfiguration();
     session         = dbConfiguration.GetSession();
     unitsRepository = new UnitsRepository(session);
 }
Beispiel #5
0
 public FuelTypesRepositoryTests()
 {
     dbConfiguration     = new DatabaseConfiguration();
     session             = dbConfiguration.GetSession();
     fuelTypesRepository = new FuelTypesRepository(session);
 }
 public CurrencyRepositoryTests()
 {
     dbConfiguration    = new DatabaseConfiguration();
     session            = dbConfiguration.GetSession();
     currencyRepository = new CurrencyRepository(session);
 }
 public QuotationValidatorTests()
 {
     quotationValidator = new QuotationValidator();
     dbConfiguration    = new DatabaseConfiguration();
     session            = dbConfiguration.GetSession();
 }
Beispiel #8
0
        public static IContainer RegisterAndResolve()
        {
            var                   builder           = new ContainerBuilder();
            Configuration         cfg               = new Configuration();
            Assembly              executingAssembly = Assembly.GetExecutingAssembly();
            DatabaseConfiguration dbConfig          = new DatabaseConfiguration();

            builder.RegisterAssemblyTypes(executingAssembly)
            .AsSelf()
            .AsImplementedInterfaces();

            builder.Register(c => cfg.BuildSessionFactory()).As <ISessionFactory>().SingleInstance();
            builder.Register(c => dbConfig.GetSession());
            //  builder.Register(c => c.Resolve<ISessionFactory>().OpenSession());


            builder.RegisterType <FuelPriceService>().As <IFuelPriceService>().InstancePerLifetimeScope();

            builder.RegisterType <QuotationsRepository>().As <IQuotationsRepository>().InstancePerLifetimeScope();

            builder.RegisterGeneric(typeof(NHibernateUniversalRepository <>)).As(typeof(INHibernateUniversalRepository <>)).OnActivating(e =>
            {
                var typeToLookup = e.Parameters.FirstOrDefault() as TypedParameter;
                if (typeToLookup != null)
                {
                    var respositoryType   = typeof(NHibernateUniversalRepository <>);
                    Type[] typeArgs       = { typeToLookup.Value.GetType() };
                    var genericType       = respositoryType.MakeGenericType(typeArgs);
                    var genericRepository = Activator.CreateInstance(genericType);
                    e.ReplaceInstance(genericRepository);
                }
            });
            builder.RegisterType <PriceListsRepository>().As <IPriceListsRepository>().InstancePerLifetimeScope();
            builder.RegisterType <FuelTypesRepository>().As <IFuelTypesRepository>().InstancePerLifetimeScope();
            builder.RegisterType <QuotationDomainService>().As <IQuotationDomainService>().InstancePerLifetimeScope();
            builder.RegisterType <DocumentsDomainService>().As <IDocumentsDomainService>().InstancePerLifetimeScope();

            builder.RegisterType <QuotationTypesRepository>().As <IQuotationTypesRepository>().InstancePerLifetimeScope();
            builder.RegisterType <UnitsRepository>().As <IUnitsRepository>().InstancePerLifetimeScope();
            builder.RegisterType <CurrencyRepository>().As <ICurrencyRepository>().InstancePerLifetimeScope();

            builder.RegisterType <DbDocumentsHelper>().As <IDbDocumentHelper>().InstancePerLifetimeScope();
            builder.RegisterType <DiskDocumentsHelper>().As <IDiskDocumentHelper>().InstancePerLifetimeScope();
            builder.RegisterType <DocumentToDocumentDbMapper>().As <IDocumentToDocumentDbMapper>().InstancePerLifetimeScope();
            builder.RegisterType <QuotationToQuotationDbMapper>().As <IQuotationToQuotationDbMapper>().InstancePerLifetimeScope();

            builder.RegisterSource(new ContravariantRegistrationSource());
            builder.RegisterAssemblyTypes(typeof(IMediator).Assembly).AsSelf().AsImplementedInterfaces();

            builder.RegisterControllers(typeof(MvcApplication).Assembly);
            builder.RegisterType <Mediator>().As <IMediator>().InstancePerLifetimeScope();
            builder.RegisterAssemblyTypes(typeof(QuotationsCommandHandler).Assembly).AsClosedTypesOf(typeof(IRequestHandler <,>));
            builder.RegisterAssemblyTypes(typeof(QuotationsCommandHandler).Assembly).AsClosedTypesOf(typeof(IRequestHandler <>));
            builder
            .Register <SingleInstanceFactory>(ctx => {
                var c = ctx.Resolve <IComponentContext>();
                return(t => { object o; return c.TryResolve(t, out o) ? o : null; });
            })
            .InstancePerLifetimeScope();

            builder
            .Register <MultiInstanceFactory>(ctx => {
                var c = ctx.Resolve <IComponentContext>();
                return(t => (IEnumerable <object>)c.Resolve(typeof(IEnumerable <>).MakeGenericType(t)));
            })
            .InstancePerLifetimeScope();
            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            return(container);
        }
 public void when_try_to_get_session_factory_database_configuration_should_not_fail()
 {
     DatabaseConfiguration cfg = new DatabaseConfiguration();
     var session = cfg.GetSession();
 }
Beispiel #10
0
 public QuotationTypesRepositoryTests()
 {
     dbConfiguration          = new DatabaseConfiguration();
     session                  = dbConfiguration.GetSession();
     quotationTypesRepository = new QuotationTypesRepository(session);
 }