public override void setupTest()
        {
            base.setupTest();
            NHibernateContextExtension wcfExtencsion = new NHibernateContextExtension(Session);

            NHibernateContext.UnitTestContext = wcfExtencsion;

            Profile profile = new Profile();

            profile.UserName            = ProfileDTO.AdministratorName;
            profile.Email               = "*****@*****.**";
            profile.Birthday            = DateTime.Now.AddYears(-30);
            profile.Privacy             = new ProfilePrivacy();
            profile.Privacy.Searchable  = false;
            profile.CountryId           = Country.GetByTwoLetters("PL").GeoId;
            profile.Licence.AccountType = AccountType.Administrator;
            insertToDatabase(profile);

            BuildDatabase();
            Session.Clear();
            manager = new SecurityManager();

            ImagesFolder = Path.Combine(Environment.CurrentDirectory, "Images");
            if (!Directory.Exists(ImagesFolder))
            {
                Directory.CreateDirectory(ImagesFolder);
            }
        }
 public void Initialize(InstanceContext instanceContext, Message message)
 {
     ISessionFactory sessionFactory = ContextRegistry
         .GetContext()
         .GetObject<ISessionFactory>(m_SessionFactory ?? @"NHibernateSessionFactory");
     ISession session = sessionFactory != null
                            ? sessionFactory.OpenSession()
                            : null;
     NHibernateContextExtension nHibernateContextExtension = new NHibernateContextExtension(session);
     instanceContext.Extensions.Add(nHibernateContextExtension);
 }
        protected void RunServiceMethod(Action <AdminService> method)
        {
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                var service = new AdminService();
                NHibernateContextExtension wcfExtencsion = new NHibernateContextExtension(serviceSession);
                NHibernateContext.UnitTestContext = wcfExtencsion;
                method(service);
            }
            Session.Clear();
        }
Exemple #4
0
        protected void RunServiceMethod(Action <InternalBodyArchitectService> method)
        {
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                var service = new InternalBodyArchitectService(serviceSession, SecurityManager, new MockEmailService(), new MockPushNotificationService());
                service.ImagesFolder = ImagesFolder;
                NHibernateContextExtension wcfExtencsion = new NHibernateContextExtension(serviceSession);
                NHibernateContext.UnitTestContext = wcfExtencsion;
                method(service);
            }
            Session.Clear();
        }
        protected void RunServiceMethod(Action <InternalBodyArchitectService> method)
        {
            var serviceSession = sessionFactory.OpenSession();

            using (serviceSession)
            {
                timerService = new MockTimerService();
                ServiceConfiguration config = new ServiceConfiguration(timerService);
                config.MethodInvoker = new NormalMethodInvoker();
                config.Payments      = paymentsManager;
                var service = new InternalBodyArchitectService(serviceSession, SecurityManager, new MockEmailService(), new MockPushNotificationService(), config);

                service.Configuration.ImagesFolder = ImagesFolder;
                NHibernateContextExtension wcfExtencsion = new NHibernateContextExtension(serviceSession);
                NHibernateContext.UnitTestContext = wcfExtencsion;
                method(service);
            }
            Session.Clear();
        }