public void ConnectionSettingsTest()
        {
            dynamic config = new Configuration();

            ConnectionSettings settings = config.Bind<ConnectionSettings>(new ConnectionSettings(_envFile));

            Assert.IsNotNull(settings);
            Assert.IsNotNullOrEmpty(settings["Redis"]);
            Assert.IsTrue(settings["Redis"].Contains(_testAddress));
        }
Exemplo n.º 2
0
        protected void Application_Start() {
            // Makes the JSON easier to read in a browser without installing an extension like JSONview
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Formatting = Formatting.Indented;

            // Stops the backing field names being used instead of the public property names (*Field & PropertyChanged etc.)
            GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            // Returns JSON to the browser without needing to add application/json to the accept request header - remove to use XML (becomes the default)
            GlobalConfiguration.Configuration.Formatters.Remove(GlobalConfiguration.Configuration.Formatters.XmlFormatter);

            // Pass Register into Configure to support attribute routing in the future
            GlobalConfiguration.Configure(WebApiConfig.Register);

            // Load settings
            dynamic config = new Configuration();
            Settings = config.Bind<HuxleySettings>();

            // Set the CRS dictionary passing in embedded CRS path
            CrsCodes = GetCrsCodes(Server.MapPath("~/RailReferences.csv")).Result;

            // https://en.wikipedia.org/wiki/London_station_group 
            // Farringdon [ZFD] is not a London Terminal but it probably should be (maybe when Crossrail opens it will be)
            LondonTerminals = new List<CrsRecord> {
                new CrsRecord {CrsCode = "BFR", StationName = "London Blackfriars",},
                new CrsRecord {CrsCode = "CST", StationName = "London Cannon Street",},
                new CrsRecord {CrsCode = "CHX", StationName = "London Charing Cross",},
                new CrsRecord {CrsCode = "CTK", StationName = "City Thameslink",},
                new CrsRecord {CrsCode = "EUS", StationName = "London Euston",},
                new CrsRecord {CrsCode = "FST", StationName = "London Fenchurch Street",},
                new CrsRecord {CrsCode = "KGX", StationName = "London Kings Cross",},
                new CrsRecord {CrsCode = "LST", StationName = "London Liverpool Street",},
                new CrsRecord {CrsCode = "LBG", StationName = "London Bridge",},
                new CrsRecord {CrsCode = "MYB", StationName = "London Marylebone",},
                new CrsRecord {CrsCode = "MOG", StationName = "Moorgate",},
                new CrsRecord {CrsCode = "OLD", StationName = "Old Street",},
                new CrsRecord {CrsCode = "PAD", StationName = "London Paddington",},
                new CrsRecord {CrsCode = "STP", StationName = "London St Pancras International",},
                new CrsRecord {CrsCode = "VXH", StationName = "Vauxhall",},
                new CrsRecord {CrsCode = "VIC", StationName = "London Victoria",},
                new CrsRecord {CrsCode = "WAT", StationName = "London Waterloo",},
                new CrsRecord {CrsCode = "WAE", StationName = "London Waterloo East",},
            };
        }
 public static void Init()
 {
     _config = new Configuration();
     // bind to this static class
     _config.Bind<AppSettings>();
 }