public void Extract_urls()
        {
            var sut = new TextCompressor();

            var urls = sut.Extract_Urls("a http://x.de b http://y.com");

            Assert.That(urls, Is.EqualTo(new[]{"http://x.de", "http://y.com"}));
        }
示例#2
0
        public void Extract_urls()
        {
            var sut = new TextCompressor();

            var urls = sut.Extract_Urls("a http://x.de b http://y.com");

            Assert.That(urls, Is.EqualTo(new[] { "http://x.de", "http://y.com" }));
        }
        public void Replace_urls()
        {
            var sut = new TextCompressor();

            var text = sut.Replace_Urls(new Tuple<string, Tuple<string, string>[]>("a http://x.de b http://y.com",
                                                                                   new[]
                                                                                       {
                                                                                           new Tuple<string, string>("http://x.de", "x"),
                                                                                           new Tuple<string, string>("http://y.com", "y")
                                                                                       }));
            Assert.AreEqual("a x b y", text);
        }
示例#4
0
        public void Replace_urls()
        {
            var sut = new TextCompressor();

            var text = sut.Replace_Urls(new Tuple <string, Tuple <string, string>[]>("a http://x.de b http://y.com",
                                                                                     new[]
            {
                new Tuple <string, string>("http://x.de", "x"),
                new Tuple <string, string>("http://y.com", "y")
            }));

            Assert.AreEqual("a x b y", text);
        }
示例#5
0
        public static void Main() {
            var mainWindow = new MainWindow();
            var mongoToken = Token.ReadFromRessource(typeof(Program).Assembly, "twitter.frontend.mongohq.credentials.txt");
            var bitlyToken = Token.ReadFromRessource(typeof(Program).Assembly, "twitter.frontend.bitly.credentials.txt");
            var accessToken = Token.ReadFromFile("access.credentials.txt");

            var tweetStore = new TweetStore(mongoToken);
            var urlShortener = new UrlShortener(bitlyToken.Key, bitlyToken.Secret);
            var textCompressor = new TextCompressor(urlShortener);
            var throttle = new Throttle<string>(2000);
            var synchronizer = new Synchronizer<string>();

            mainWindow.TweettextChanged += throttle.Process;

            throttle.Result += t =>
            {
                var shortText = textCompressor.Compress(t);
                synchronizer.Process(shortText);
            };

            synchronizer.Result += mainWindow.ShowTweetText;


            mainWindow.Tweet += (text, veröffentlichen) => {
                var tweet = new Tweet {
                    AccessToken = accessToken.Key,
                    OAuthToken = accessToken.Secret,
                    Text = text,
                    Veröffentlichen = veröffentlichen
                };
                tweetStore.Speichern(tweet);
            };
            
            var app = new Application {
                MainWindow = mainWindow
            };
            app.Run(mainWindow);
        }