Exemplo n.º 1
0
        public async Task TestSkye()
        {
            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            var coords = await locationFinder.GetLocationFromStringAsync("Skye");

            Assert.NotNull(coords);
        }
Exemplo n.º 2
0
        public async Task TestWesternIsles()
        {
            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            var coords = await locationFinder.GetLocationFromStringAsync("Stornoway");

            Assert.NotNull(coords);
            Assert.AreEqual(coords.AdminDistrict2, "Na h-Eileanan Siar");
        }
Exemplo n.º 3
0
        public async Task Alva()
        {
            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            var coords = await locationFinder.GetLocationFromStringAsync("Alva");

            Assert.NotNull(coords);
            Assert.AreEqual(coords.AdminDistrict2, "Clackmannanshire");
        }
Exemplo n.º 4
0
        public async Task BaseGeoTest()
        {
            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            var coords = await locationFinder.GetLocationFromStringAsync("Edinburgh");

            Assert.NotNull(coords);
            Assert.AreEqual(coords.AdminDistrict2, "City of Edinburgh");
        }
Exemplo n.º 5
0
        public async Task NotNullLocations(string location)
        {
            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            var coords = await locationFinder.GetLocationFromStringAsync(location);

            Assert.NotNull(coords);
            System.Threading.Thread.Sleep(100);//don't overload bing
        }
Exemplo n.º 6
0
        private static Task MainAsync(string[] args)
        {
            //https://blog.bitscry.com/2017/05/30/appsettings-json-in-net-core-console-app/
            //https://blogs.msdn.microsoft.com/fkaduk/2017/02/22/using-strongly-typed-configuration-in-net-core-console-app/
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetParent(AppContext.BaseDirectory).FullName)
                          .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);

            IConfigurationRoot config = builder.Build();

            //PurpleFridayTweetListener.

            var streamConfig = new TwitterAuthConfig();

            config.Bind("TwitterCredentials", streamConfig);

            var dataForwarderConfig = new DataForwarderConfiguration();

            config.Bind("DataForwarder", dataForwarderConfig);
            dataForwarderConfig.BaseUrl = new Uri(config["DataForwarder:BaseUri"]);

            if (bool.Parse(config["Logging:LogToFile"]))
            {
                // Log to console and file.
                Logging.SetupLogging(config["Logging:LogFolderPath"]);
            }
            else
            {
                // Log to console only.
                Logging.SetupLogging(null);
            }

            Logging.Information("Starting PurpleFridayTweetListener");

            var tweetListenerConfig = new TweetListenerConfig();

            config.Bind("Listener", tweetListenerConfig);

            var locationFinderConfig = new LocationFinderConfiguration();

            config.Bind("LocationFinder", locationFinderConfig);

            var locationFinder = new LocationFinder.LocationFinder(locationFinderConfig, new BingMapsGeocoder(locationFinderConfig.BingMapsKey));

            var tweetListener = new TweetListener(streamConfig, tweetListenerConfig, new DataForwarderFactory(dataForwarderConfig), locationFinder);

            tweetListener.StartStream(args.Any()? args[0]: tweetListenerConfig.Filter);

            Console.Read();

            return(null);
        }
Exemplo n.º 7
0
        public async Task TestOverride()
        {
            Dictionary <string, string> testLocations = new Dictionary <string, string>();

            testLocations["northqueensferry"] = "North Queensferry";
            testLocations["skye"]             = "Isle of Skye";
            testLocations["standrews"]        = "St Andrews";
            testLocations["johnogroats"]      = "John O'Groats";
            testLocations["nothere"]          = "nothere";  // Return back what was passed.


            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            foreach (var location in testLocations)
            {
                var overrideString = locationFinder.InvokeLocationOverrideOrReturnOriginal(location.Key);
                Assert.AreEqual(overrideString, location.Value);
            }
        }
Exemplo n.º 8
0
        public async Task TestForScotlandOnly()
        {
            Dictionary <string, string> testLocations = new Dictionary <string, string>();

            testLocations["Banff"]         = "Aberdeenshire";
            testLocations["Inverkeithing"] = "Fife";
            testLocations["Perth"]         = "Perth and Kinross";
            testLocations["johnogroats"]   = "Highland";


            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

            foreach (var location in testLocations)
            {
                var coords = await locationFinder.GetLocationFromStringAsync(location.Key);

                Assert.NotNull(coords);
                Assert.AreEqual(coords.AdminDistrict2, location.Value);

                System.Threading.Thread.Sleep(1000);//don't overload bing
            }
        }