public static Config.Config InitApp(HttpConfiguration httpConfig, Service.Config.Config config = null) { XmlConfigurator.Configure(); GlobalContext.Properties["Version"] = typeof(MainController).Assembly.GetName().Version; config = config ?? ReadConfig(); if (config.Environment == "Development") { new Development().Run(config); } else { new Production().Run(config); } //в тестах мы можем запустить две копии приложения if (SessionFactory == null) { var nhibernate = new Config.Initializers.NHibernate(); nhibernate.Init(); SessionFactory = nhibernate.Factory; } ReadDbConfig(config); var mvc = new Mvc(); mvc.Run(httpConfig, SessionFactory, config); new Config.Initializers.SmartOrderFactory().Init(SessionFactory); return(config); }
public void Setup() { Assert.IsNull(server); if (!Directory.Exists(IntegrationSetup.BackupDir)) { return; } Prepare(@"..\..\..\app\bin\Debug", "acceptance"); Url = InitHelper.RandomPort(); var result = InitHelper.InitService(Url).Result; server = result.Item1; Config = result.Item2; Configure("acceptance", Url.ToString()); }
public void MixedFixtureSetup() { //в качестве начального значения используется время если оно совпадет то и значения будут идентичные //для этого тесты должны иметь общий генератор случайных чисел random = new Random(); begin = DateTime.Now; SystemTime.Reset(); cleaner = new FileCleaner(); disposable = new CompositeDisposable(); disposable.Add(cleaner); fixtureHelper = new FixtureHelper(); disposable.Add(fixtureHelper); clientConfig = Integration.IntegrationSetup.clientConfig; serviceConfig = Integration.IntegrationSetup.serviceConfig; FileHelper.InitDir(serviceConfig.RtmUpdatePath, clientConfig.TmpDir, Path.Combine(ConfigurationManager.AppSettings["ClientDocPath"], "АналитФАРМАЦИЯ")); localSession = Integration.IntegrationSetup.Factory.OpenSession(); localStateless = Integration.IntegrationSetup.Factory.OpenStatelessSession(); settings = localSession.Query <Settings>().First(); address = localSession.Query <Address>().First(); ViewModelFixture.StubWindowManager(); var debugTest = Environment.GetEnvironmentVariable("DEBUG_TEST"); if (debugTest.Match(TestContext.CurrentContext.Test.Name)) { var repository = (Hierarchy)LogManager.GetRepository(); repository.Configured = true; var logger = (Logger)repository.GetLogger("AnalitF.Net"); if (logger.Level == null || logger.Level > Level.Warn) { logger.Level = Level.Warn; } var appender = new ConsoleAppender(new PatternLayout(PatternLayout.DefaultConversionPattern)); appender.ActivateOptions(); logger.AddAppender(appender); } }
public void Setup() { Assert.IsNull(server); Directory.CreateDirectory("var"); clientConfig.DiadokApiKey = "Analit-988b9e85-1b8e-40a9-b6bd-543790d0a7ec"; clientConfig.DiadokUrl = "https://diadoc-api.kontur.ru"; clientConfig.BaseUrl = InitHelper.RandomPort(); clientConfig.RootDir = @"var\client"; clientConfig.RequestInterval = 1.Second(); clientConfig.InitDir(); Consts.ScrollLoadTimeout = TimeSpan.Zero; LogManager.GetLog = t => new Log4net(t); AppBootstrapper.InitUi(true); global::Test.Support.Setup.SessionFactory = DbHelper.ServerNHConfig("server"); var result = InitHelper.InitService(clientConfig.BaseUrl).Result; server = result.Item1; serviceConfig = result.Item2; var nhibernate = new Client.Config.NHibernate.NHibernate(); AppBootstrapper.NHibernate = nhibernate; AppBootstrapper.NHibernate.Init("client"); Factory = nhibernate.Factory; Configuration = nhibernate.Configuration; if (IsServerStale()) { FileHelper.InitDir(clientConfig.DbDir, BackupDir); } if (IsClientStale()) { ImportData(); DbHelper.CopyDb(BackupDir); } DbHelper.SeedDb(); }
public static async Task <Tuple <HttpSelfHostServer, Service.Config.Config> > InitService(Uri url, Service.Config.Config config = null) { var cfg = new HttpSelfHostConfiguration(url) { IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always, HostNameComparisonMode = HostNameComparisonMode.Exact }; config = Application.InitApp(cfg, config); config.UpdateLifeTime = TimeSpan.FromDays(1); var server = new HttpSelfHostServer(cfg); await server.OpenAsync(); return(Tuple.Create(server, config)); }