public void Init()
 {
     // Those simulate the parameters created by DefaultUrlBuilder
     standardRouteParamsWithArea    = DictHelper.Create("area=area", "controller=home", "action=index");
     standardRouteParamsWithoutArea = DictHelper.Create("area=", "controller=home", "action=index");
 }
        public void ShouldNotMatchIfParameterIsNotPresent()
        {
            var route = new PatternRoute("/some/<controller>");

            Assert.IsNull(route.CreateUrl(DictHelper.Create("")));
        }
Beispiel #3
0
 public string For()
 {
     return(For(DictHelper.Create()));
 }
Beispiel #4
0
 /// <summary>
 /// OnParametersSet 方法
 /// </summary>
 public override System.Threading.Tasks.Task SetParametersAsync(ParameterView parameters)
 {
     parameters.SetParameterProperties(this);
     FixedHeader = DictHelper.RetrieveFixedTableHeader();
     return(base.SetParametersAsync(ParameterView.Empty));
 }
Beispiel #5
0
        private async Task <IActionResult> SignInAsync(string userName, bool persistent, string authenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme)
        {
            var identity = new ClaimsIdentity(authenticationScheme);

            identity.AddClaim(new Claim(ClaimTypes.Name, userName));
            await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity), new AuthenticationProperties { ExpiresUtc = DateTimeOffset.Now.AddDays(DictHelper.RetrieveCookieExpiresPeriod()), IsPersistent = persistent });

            // redirect origin url
            var originUrl = Request.Query[CookieAuthenticationDefaults.ReturnUrlParameter].FirstOrDefault() ?? "~/Home/Index";

            return(Redirect(originUrl));
        }
Beispiel #6
0
        public static string LinkTo(this UrlHelper urlHelper, string name, string action)
        {
            var str = urlHelper.For(DictHelper.Create(new[] { "action=" + action }));

            return(string.Format("<a href=\"{0}\">{1}</a>", str, name));
        }
Beispiel #7
0
 public void RetrieveIconFolderPath_Ok()
 {
     Assert.Equal("~/images/uploader/", DictHelper.RetrieveIconFolderPath());
 }
Beispiel #8
0
        public static string GetEasyUIControl(ColumnEntity col, bool isQuery)
        {
            string     field      = col.Field.capitalize();
            string     queryField = (isQuery ? "query-" : "") + field;
            TagBuilder tag        = new TagBuilder();

            tag.TagName = "input";
            TagReanderMode mode = TagReanderMode.SelfClosing;

            tag.AddAttribute("id", isQuery ? queryField : field);
            if (!isQuery)
            {
                tag.AddAttribute("name", queryField);
            }
            Dictionary <string, object> options = new Dictionary <string, object>();

            if (col.Required && !isQuery)
            {
                options.Add("required", true);
                options.Add("missingmessage", col.Display + "必填");
            }
            switch (col.EditorType)
            {
            case WSH.CodeBuilder.DispatchServers.EditorType.TextBox:

            case WSH.CodeBuilder.DispatchServers.EditorType.TextBoxLine:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", isQuery ? "textbox" : "easyui-validatebox textbox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.TextArea:
            {
                tag.TagName = "textarea";
                tag.AddAttribute("class", isQuery ? "textbox" : "easyui-validatebox textbox");
                mode = TagReanderMode.Normal;
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.RichTextBox:
            {
                tag.TagName = "textarea";
                mode        = TagReanderMode.Normal;
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.NumberBox:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", "easyui-numberbox textbox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.IntBox:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", "easyui-numberbox textbox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.UIntBox:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", "easyui-numberbox textbox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.DateBox:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", "easyui-datepicker textbox");
                //if (!string.IsNullOrEmpty(col.FormatString))
                //{
                //    tag.AddAttribute("DateFmt", col.FormatString);
                //}
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.CheckBox:
            {
                tag.AddAttribute("type", "checkbox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.ComboBox:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", "easyui-combobox combobox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.SearchBox:
            {
                tag.AddAttribute("type", "text");
                tag.AddAttribute("class", "easyui-searchbox textbox");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.FileUpload:
            {
                tag.AddAttribute("type", "file");
            }
            break;

            case WSH.CodeBuilder.DispatchServers.EditorType.Template:
            {
                tag.TagName = "div";
                mode        = TagReanderMode.Normal;
            }
            break;
            }
            string dataOptions = DictHelper.ToJsonItem(options);

            if (!string.IsNullOrEmpty(dataOptions))
            {
                tag.AddAttribute("data-options", dataOptions);
            }
            return(tag.ToString(mode));
        }
Beispiel #9
0
 public void RetrieveThemes_Ok()
 {
     Assert.NotEmpty(DictHelper.RetrieveThemes());
 }
Beispiel #10
0
 public void RetrieveActiveTheme_Ok()
 {
     Assert.Equal("blue.css", DictHelper.RetrieveActiveTheme());
 }
Beispiel #11
0
 public void RetrieveWebFooter_Ok()
 {
     Assert.Equal("2016 © 通用后台管理系统", DictHelper.RetrieveWebFooter());
 }
Beispiel #12
0
 public void RetrieveWebTitle_Ok()
 {
     Assert.Equal("后台管理系统", DictHelper.RetrieveWebTitle());
 }
Beispiel #13
0
 public void RetrieveCategories_Ok()
 {
     Assert.NotEmpty(DictHelper.RetrieveCategories());
 }
		public void SetUp()
		{
			var en = CultureInfo.CreateSpecificCulture("en");

			Thread.CurrentThread.CurrentCulture = en;
			Thread.CurrentThread.CurrentUICulture = en;

			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			var services = new StubMonoRailServices
			               	{
			               		UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()),
			               		UrlTokenizer = new DefaultUrlTokenizer(),
			               		CacheProvider = new StubCacheProvider()
			               	};
			services.AddService(typeof(ICacheProvider), services.CacheProvider);

			var urlInfo = new UrlInfo(
				"example.org", "test", "", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			Response = new StubResponse();
			EngineContext = new StubEngineContext(new StubRequest(), Response, services,
			                                          urlInfo);

			services.AddService(typeof(IEngineContext), EngineContext);
			EngineContext.AddService<IEngineContext>(EngineContext);

			EngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			EngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			EngineContext.AddService<ICacheProvider>(services.CacheProvider);

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(EngineContext);

			EngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			services.AddService(typeof(IViewComponentFactory), ViewComponentFactory);

			EngineContext.AddService<IViewComponentDescriptorProvider>(new DefaultViewComponentDescriptorProvider());
			services.AddService(typeof(IViewComponentDescriptorProvider), EngineContext.GetService<IViewComponentDescriptorProvider>());

			ControllerContext = new ControllerContext { Helpers = Helpers, PropertyBag = PropertyBag };
			EngineContext.CurrentControllerContext = ControllerContext;

			Helpers["formhelper"] = Helpers["form"] = new FormHelper(EngineContext);
			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(EngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(EngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(EngineContext);

			var viewPath = Path.Combine(ViewSourcePath, "Views");

			var loader = new FileAssemblyViewSourceLoader(viewPath);

			services.ViewSourceLoader = loader;
			services.AddService(typeof(IViewSourceLoader), services.ViewSourceLoader);
			EngineContext.AddService<IViewSourceLoader>(services.ViewSourceLoader);

			Controller = new BaseTestFixtureController();
			Controller.Contextualize(EngineContext, ControllerContext);

			VelocityViewEngine = new NVelocityViewEngine();
			services.AddService(typeof(IViewEngine), VelocityViewEngine);
			EngineContext.AddService<IViewEngine>(VelocityViewEngine);

			VelocityViewEngine.SetViewSourceLoader(loader);
			VelocityViewEngine.Service(services);

			var viewEngineManager = new DefaultViewEngineManager();
			viewEngineManager.RegisterEngineForExtesionLookup(VelocityViewEngine);
			services.EmailTemplateService = new EmailTemplateService(viewEngineManager);

			BeforEachTest();
		}
 public IEnumerable <BootstrapDict> RetrieveDicts()
 {
     return(DictHelper.RetrieveDicts());
 }
Beispiel #16
0
 public void IPSvrCachePeriod_Ok()
 {
     Assert.Equal("10", DictHelper.RetrieveLocaleIPSvrCachePeriod());
 }
Beispiel #17
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="controller"></param>
 public NavigatorBarModel(ControllerBase controller) : base(controller)
 {
     Navigations = MenuHelper.RetrieveAppMenus(UserName, $"~/{controller.ControllerContext.ActionDescriptor.ControllerName}/{controller.ControllerContext.ActionDescriptor.ActionName}");
     ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
 }
Beispiel #18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="po"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="opType"></param>
        /// <returns></returns>
        public override Page <DataAccess.Log> RetrievePages(PaginationOption po, DateTime?startTime, DateTime?endTime, string opType)
        {
            var filterBuilder = Builders <DataAccess.Log> .Filter;
            var filter        = filterBuilder.Empty;

            if (startTime.HasValue)
            {
                filter = filterBuilder.Gte("LogTime", startTime.Value);
            }
            if (endTime.HasValue)
            {
                filter = filterBuilder.Lt("LogTime", endTime.Value.AddDays(1).AddSeconds(-1));
            }
            if (startTime == null && endTime == null)
            {
                filter = filterBuilder.Gt("LogTime", DateTime.Today.AddMonths(0 - DictHelper.RetrieveAccessLogPeriod()));
            }
            if (!string.IsNullOrEmpty(opType))
            {
                filter = filterBuilder.Eq("CRUD", opType);
            }

            // sort
            var sortBuilder = Builders <DataAccess.Log> .Sort;
            SortDefinition <DataAccess.Log> sort = null;

            switch (po.Sort)
            {
            case "CRUD":
                sort = po.Order == "asc" ? sortBuilder.Ascending(t => t.CRUD) : sortBuilder.Descending(t => t.CRUD);
                break;

            case "UserName":
                sort = po.Order == "asc" ? sortBuilder.Ascending(t => t.UserName) : sortBuilder.Descending(t => t.UserName);
                break;

            case "LogTime":
                sort = po.Order == "asc" ? sortBuilder.Ascending(t => t.LogTime) : sortBuilder.Descending(t => t.LogTime);
                break;

            case "Ip":
                sort = po.Order == "asc" ? sortBuilder.Ascending(t => t.Ip) : sortBuilder.Descending(t => t.Ip);
                break;

            case "RequestUrl":
                sort = po.Order == "asc" ? sortBuilder.Ascending(t => t.RequestUrl) : sortBuilder.Descending(t => t.RequestUrl);
                break;
            }

            var logs = DbManager.Logs.Find(filter).Sort(sort).ToList();

            return(new Page <DataAccess.Log>()
            {
                Context = logs,
                CurrentPage = po.PageIndex,
                ItemsPerPage = po.Limit,
                TotalItems = logs.Count,
                TotalPages = (long)Math.Ceiling(logs.Count * 1.0 / po.Limit),
                Items = logs.Skip(po.Offset).Take(po.Limit).ToList()
            });
        }
Beispiel #19
0
        protected async override System.Threading.Tasks.Task CreatFormatter()
        {
            Dictionary <string, string> dic = new Dictionary <string, string>()
            {
                { "1", "巨鹿县医院" }, { "3", "巨鹿祈康医院" },
                { "2", "巨鹿健民医院" }
            };
            IReportService service    = IOCContainer.Instance.Resolve <IReportService>();
            ILtcService    ltcService = IOCContainer.Instance.Resolve <ILtcService>();
            var            sDate      = StartTime.ToString("yyyy-MM");
            var            eDate      = EndTime.ToString("yyyy-MM");
            BaseResponse <IList <TreatmentAccount> > res = new BaseResponse <IList <TreatmentAccount> >();
            BaseRequest request = new BaseRequest()
            {
                CurrentPage = 1, PageSize = 1000
            };

            res = ltcService.GetResMonthData(request, sDate, eDate, NsId) as BaseResponse <IList <TreatmentAccount> >;
            List <PrintMonthFee> list   = new List <PrintMonthFee>();
            List <Ipdregout>     resIpd = new List <Ipdregout>();

            try
            {
                var result = await HttpClientHelper.NciHttpClient.GetAsync("/api/Ipd?nsno=" + NsId);

                resIpd = result.Content.ReadAsAsync <List <Ipdregout> >().Result;
            }
            catch
            {
                throw new NOContactException();
            }
            try
            {
                list = service.GetPrintData(res, resIpd);
            }
            catch
            {
                throw new NoDataException();
            }

            var parameterContainer = new WorkbookParameterContainer();

            parameterContainer.Load(TemplateFormatterPath);
            SheetParameterContainer sheetContainer = parameterContainer["Sheet1"];
            var dataFormatter = new List <ElementFormatter>();

            dataFormatter.Add(new CellFormatter(sheetContainer["Org"], "单位:" + dic[SecurityHelper.CurrentPrincipal.OrgId] + "  " + GetOrgName(SecurityHelper.CurrentPrincipal.OrgId)));
            dataFormatter.Add(new CellFormatter(sheetContainer["Date"], "核算时间:"
                                                + DictHelper.GetFeeIntervalByYearMonth(StartTime.ToString("yyyy-MM")).StartDate + "-" + DictHelper.GetFeeIntervalByYearMonth(EndTime.ToString("yyyy-MM")).EndDate));
            dataFormatter.Add(new CellFormatter(sheetContainer["THospDay"], list.Sum(s => s.HospDay)));
            dataFormatter.Add(new CellFormatter(sheetContainer["TTotalAmount"], list.Sum(s => s.TotalAmount)));
            dataFormatter.Add(new CellFormatter(sheetContainer["TNCIPay"], list.Sum(s => s.NCIPay)));
            var indexNum       = 1;
            var tableFormatter = new TableFormatter <PrintMonthFee>(sheetContainer["Index"], list,
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["Index"], t => indexNum++),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["Name"], t => t.Name),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["Sex"], t => t.Sex),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["ResidentSSId"], t => t.ResidentSSId),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["BrithPlace"], t => t.BrithPlace),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["RsStatus"], t => t.RsStatus),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["DiseaseDiag"], t => t.DiseaseDiag),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["CareType"], t => t.CareTypeId),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["CertStartTime"], t => t.EvaluationTime.Value.ToString("yyyy-MM-dd")),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["InDate"], t => t.InDate.Value.ToString("yyyy-MM-dd")),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["OutDate"], t => t.OutDate.Value.ToString("yyyy-MM-dd")),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["HospDay"], t => t.HospDay),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["TotalAmount"], t => t.TotalAmount),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["NCIPayLevel"], t => t.NCIPayLevel),
                                                                    new CellFormatter <PrintMonthFee>(sheetContainer["NCIPay"], t => t.NCIPay));

            dataFormatter.Add(tableFormatter);
            Formatter = new SheetFormatter("Sheet1", dataFormatter.ToArray());
        }
Beispiel #20
0
        public static string LinkTo(this UrlHelper urlHelper, string name, string controller, string action, object id)
        {
            var str = urlHelper.For(DictHelper.Create(new[] { "controller=" + controller, "action=" + action }));

            return(string.Format("<a href=\"{0}?id={1}\">{2}</a>", str, id, name));
        }
Beispiel #21
0
        /// <summary>
        /// 默认构造函数
        /// </summary>
        /// <param name="userName"></param>
        public HeaderBarModel(string?userName)
        {
            var user = UserHelper.RetrieveUserByUserName(userName);

            if (user != null)
            {
                Icon        = user.Icon.Contains("://", StringComparison.OrdinalIgnoreCase) ? user.Icon : string.Format("{0}{1}", DictHelper.RetrieveIconFolderPath(), user.Icon);
                DisplayName = user.DisplayName;
                UserName    = user.UserName;
                AppId       = user.App;
                Css         = user.Css;
                ActiveCss   = string.IsNullOrEmpty(Css) ? Theme : Css;

                // 当前用户未设置应用程序时 使用当前配置 appId
                if (AppId.IsNullOrEmpty())
                {
                    AppId = BootstrapAppContext.AppId;
                }

                // 通过 AppCode 获取用户默认应用的标题
                Title  = DictHelper.RetrieveWebTitle(AppId);
                Footer = DictHelper.RetrieveWebFooter(AppId);

                // feat: https://gitee.com/LongbowEnterprise/dashboard/issues?id=I12VKZ
                // 后台系统网站图标跟随个人中心设置的默认应用站点的展示
                WebSiteIcon = DictHelper.RetrieveWebIcon(AppId);
                WebSiteLogo = DictHelper.RetrieveWebLogo(AppId);
            }
            EnableBlazor = DictHelper.RetrieveEnableBlazor();
        }
Beispiel #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="controller"></param>
 public ThemeModel(ControllerBase controller) : base(controller)
 {
     Themes = DictHelper.RetrieveThemes();
 }
Beispiel #23
0
 private void CbxWordbook_MouseEnter(object sender, EventArgs e)
 {
     wordbookList = DictHelper.GenerateDictList();
     wordbookDict = DictHelper.ReadDictDict();
 }
Beispiel #24
0
 public string For(Type type)
 {
     return(For(type, DictHelper.Create()));
 }
Beispiel #25
0
 public void Init()
 {
     helper = new DictHelper();
 }
Beispiel #26
0
 /// <summary>
 /// Redirects to the specified url
 /// </summary>
 /// <param name="url">An relative or absolute URL to redirect the client to</param>
 /// <param name="queryStringParameters">The querystring entries</param>
 public void RedirectToUrl(string url, params string[] queryStringParameters)
 {
     RedirectToUrl(url, DictHelper.Create(queryStringParameters));
 }
Beispiel #27
0
 /// <summary>
 /// 預設構造函数
 /// </summary>
 /// <param name="appId"></param>
 public LoginModel(string?appId = null) : base(appId)
 {
     ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
 }
        public void ShouldNotMatchStaticRule()
        {
            var route = new PatternRoute("/some/path");

            Assert.IsNull(route.CreateUrl(DictHelper.Create("")));
        }
Beispiel #29
0
 public bool Post([FromBody] IEnumerable <BootstrapDict> values) => DictHelper.SaveUISettings(values);
		public void SetUp()
		{
			var siteRoot = GetSiteRoot();
			var viewPath = Path.Combine(siteRoot, "RenderingTests\\Views");
			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			var services = new StubMonoRailServices
			{
				UrlBuilder = new DefaultUrlBuilder(new StubServerUtility(), new StubRoutingEngine()), 
				UrlTokenizer = new DefaultUrlTokenizer()
			};
			var urlInfo = new UrlInfo(
				"example.org", "test", "/TestBrail", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			StubEngineContext = new StubEngineContext(new StubRequest(), new StubResponse(), services,
													  urlInfo);
			StubEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			StubEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			StubEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			StubEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
			StubEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
			

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(StubEngineContext);

			ControllerContext = new ControllerContext
			{
				Helpers = Helpers, 
				PropertyBag = PropertyBag
			};
			StubEngineContext.CurrentControllerContext = ControllerContext;


			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(StubEngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(StubEngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(StubEngineContext);


			//FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
//			loader.AddAssemblySource(
//				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
//									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

			viewEngine = new AspViewEngine();
			var options = new AspViewEngineOptions();
			options.CompilerOptions.AutoRecompilation = true;
			options.CompilerOptions.KeepTemporarySourceFiles = false;
			((IAspViewEngineTestAccess)viewEngine).SetOptions(options);
			ICompilationContext context =
				new CompilationContext(
					new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory),
					new DirectoryInfo(siteRoot),
					new DirectoryInfo(Path.Combine(siteRoot, "RenderingTests\\Views")),
					new DirectoryInfo(siteRoot));

			var compilationContexts = new List<ICompilationContext> { context };
			((IAspViewEngineTestAccess)viewEngine).SetCompilationContext(compilationContexts);
			viewEngine.Service(StubEngineContext);
		}
Beispiel #31
0
 /// <summary>
 ///
 /// </summary>
 public LoginModel()
 {
     ImageLibUrl = DictHelper.RetrieveImagesLibUrl();
 }
		public void SetUp()
		{
			string viewPath = Path.Combine(SiteRoot, "Views");
			Layout = null;
			PropertyBag = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
			Helpers = new HelperDictionary();
			MockServices services = new MockServices();
			services.UrlBuilder = new DefaultUrlBuilder(new MockServerUtility(), new MockRoutingEngine());
			services.UrlTokenizer = new DefaultUrlTokenizer();
			UrlInfo urlInfo = new UrlInfo(
				"example.org", "test", "/TestBrail", "http", 80,
				"http://test.example.org/test_area/test_controller/test_action.tdd",
				Area, ControllerName, Action, "tdd", "no.idea");
			MockEngineContext = new MockEngineContext(new MockRequest(), new MockResponse(), services,
													  urlInfo);
			MockEngineContext.AddService<IUrlBuilder>(services.UrlBuilder);
			MockEngineContext.AddService<IUrlTokenizer>(services.UrlTokenizer);
			MockEngineContext.AddService<IViewComponentFactory>(ViewComponentFactory);
			MockEngineContext.AddService<ILoggerFactory>(new ConsoleFactory());
			MockEngineContext.AddService<IViewSourceLoader>(new FileAssemblyViewSourceLoader(viewPath));
			

			ViewComponentFactory = new DefaultViewComponentFactory();
			ViewComponentFactory.Service(MockEngineContext);
			ViewComponentFactory.Initialize();

			ControllerContext = new ControllerContext();
			ControllerContext.Helpers = Helpers;
			ControllerContext.PropertyBag = PropertyBag;
			MockEngineContext.CurrentControllerContext = ControllerContext;


			Helpers["urlhelper"] = Helpers["url"] = new UrlHelper(MockEngineContext);
			Helpers["htmlhelper"] = Helpers["html"] = new HtmlHelper(MockEngineContext);
			Helpers["dicthelper"] = Helpers["dict"] = new DictHelper(MockEngineContext);
			Helpers["DateFormatHelper"] = Helpers["DateFormat"] = new DateFormatHelper(MockEngineContext);


			//FileAssemblyViewSourceLoader loader = new FileAssemblyViewSourceLoader(viewPath);
//			loader.AddAssemblySource(
//				new AssemblySourceInfo(Assembly.GetExecutingAssembly().FullName,
//									   "Castle.MonoRail.Views.Brail.Tests.ResourcedViews"));

			viewEngine = new AspViewEngine();
			viewEngine.Service(MockEngineContext);
			AspViewEngineOptions options = new AspViewEngineOptions();
			options.CompilerOptions.AutoRecompilation = true;
			options.CompilerOptions.KeepTemporarySourceFiles = false;
			string root = AppDomain.CurrentDomain.BaseDirectory;
			root = root.Substring(0, root.LastIndexOf("Bin\\Debug", StringComparison.InvariantCultureIgnoreCase));
			ICompilationContext context = 
				new CompilationContext(
					new DirectoryInfo(root + @"\Bin\Debug"),
					new DirectoryInfo(root),
					new DirectoryInfo(root + @"\RenderingTests\Views"),
					new DirectoryInfo(root));
			viewEngine.Initialize(context, options);
			System.Console.WriteLine("init");

			BeforEachTest();
		}
Beispiel #33
0
 public void RetrieveAccessLogPeriod_Ok()
 {
     Assert.Equal(1, DictHelper.RetrieveAccessLogPeriod());
 }