コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        public async Task TestSkye()
        {
            var locationFinder = new LocationFinder(new LocationFinderConfiguration {
                BingMapsKey = MAPS_KEY
            }, geocoder);

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

            Assert.NotNull(coords);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        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");
        }
コード例 #3
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        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");
        }
コード例 #4
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        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");
        }
コード例 #5
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        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
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: impact48/PurpleFriday
        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);
        }
コード例 #7
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        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);
            }
        }
コード例 #8
0
ファイル: UnitTest1.cs プロジェクト: impact48/PurpleFriday
        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
            }
        }