public void TestHostInDevEnvironment()
        {
            var parameters = new NameValueCollection();
            parameters.Add("Environment", "test");
            parameters.Add("BridgeWsUrl", "http://localhost:59822/");
            var config = new AppConfig(parameters);

            Assert.AreEqual("", new FingertipsUrl(config).Host);
        }
        public void TestHostInLiveEnvironment()
        {
            var parameters = new NameValueCollection();
            parameters.Add("Environment", "live");
            parameters.Add("BridgeWsUrl", "http://fingertips.phe.org.uk/");
            var config = new AppConfig(parameters);

            var skin = ReaderFactory.GetProfileReader().GetSkinFromId(SkinIds.Core);
            Assert.AreEqual("http://" + skin.LiveHost, new FingertipsUrl(config).Host);
        }
        public static Skin GetSkin()
        {
            var appSettings = new AppConfig(AppConfig.AppSettings);
            var hostName = HttpContext.Current.Request.Url.Host;
            var reader = ReaderFactory.GetProfileReader();

            Skin skin = appSettings.IsSkinOverride ?
                reader.GetSkinFromName(appSettings.SkinOverride) :
                reader.GetSkin(appSettings.Environment, hostName);

            if (skin == null)
            {
                var message = string.IsNullOrWhiteSpace(appSettings.SkinOverride) ?
                            "SkinOverride is not set in Web.Config and skin cannot be identified from the URL host."            
                            : string.Format("SkinOverride {0} is not valid.  Please set a correct value in Web.Config", appSettings.SkinOverride) ;
        
                HttpContext.Current.Response.ClearContent();    // to handle any chain of calls
                HttpContext.Current.Response.Write(message);
                throw new ApplicationException(message);
            }
            
            skin.Host = hostName;
            return skin;
        }
 public PageModel(AppConfig appConfig)
 {
     this.appConfig = appConfig;
     ProfileId = ProfileIds.Undefined;
 }
        public ErrorPageModel(AppConfig appConfig)
            : base(appConfig)
        {

        }
 public ProfileCollectionBuilder(ProfileReader profileReader, AppConfig config)
 {
     this.profileReader = profileReader;
     this.config = config;
 }
        public void TestCoreWsUrlForLogging_UsesCoreWsUrlIfNotSet()
        {
            NameValueCollection parameters = new NameValueCollection();
            parameters.Add("CoreWsUrl", "1");
            parameters.Add("CoreWsUrlForLogging", "2");
            var config = new AppConfig(parameters);
            Assert.IsTrue(config.CoreWsUrlForLogging.Contains("2"));

            parameters = new NameValueCollection();
            parameters.Add("CoreWsUrl", "1");
            config = new AppConfig(parameters);
            Assert.IsTrue(config.CoreWsUrlForLogging.Contains("1"));
        }
 public FingertipsUrl(AppConfig appConfig)
 {
     this.appConfig = appConfig;
 }