public void SetUp() { var shortener = new GoogleUrlShortener(); this.shortener = shortener; shortener.HttpClient = new HttpClient(Mocks.HttpMessageHandlerRecorder.CreatePlayback()); }
/// <summary> /// Shortens the specified long URL, but leaves the fragment part (if present) visibly applied to the shortened URL. /// </summary> /// <param name="shortener">The URL shortening service to use.</param> /// <param name="longUrl">The long URL.</param> /// <param name="cancellationToken">A cancellation token.</param> /// <returns>The short URL.</returns> public static async Task <Uri> ShortenExcludeFragmentAsync(this IUrlShortener shortener, Uri longUrl, CancellationToken cancellationToken = default(CancellationToken)) { Requires.NotNull(shortener, "shortener"); Uri longUriWithoutFragment; if (longUrl.Fragment.Length == 0) { longUriWithoutFragment = longUrl; } else { var removeFragmentBuilder = new UriBuilder(longUrl); removeFragmentBuilder.Fragment = null; longUriWithoutFragment = removeFragmentBuilder.Uri; } var shortUrl = await shortener.ShortenAsync(longUriWithoutFragment, cancellationToken).ConfigureAwait(false); if (longUrl.Fragment.Length > 0) { var addFragmentBuilder = new UriBuilder(shortUrl); addFragmentBuilder.Fragment = longUrl.Fragment.Substring(1); shortUrl = addFragmentBuilder.Uri; } return(shortUrl); }
/// <summary> /// Initializes a new instance of the <see cref="FeedController" /> class. /// </summary> /// <param name="blogRepository">The blog repository.</param> /// <param name="projectRepository">Project repository</param> /// <param name="siteConfig">Site configuration</param> /// <param name="urlShortener">URL shortener</param> public FeedController(IBlogRepository blogRepository, IProjectRepository projectRepository, ISiteConfiguration siteConfig, IUrlShortener urlShortener) { _blogRepository = blogRepository; _projectRepository = projectRepository; _siteConfig = siteConfig; _urlShortener = urlShortener; }
/// <summary> /// Initializes a new instance of the <see cref="ShrinkUrlTwitterFormattingStrategy"/> class. /// </summary> /// <param name="urlShortener">The URL shortener.</param> public ShrinkUrlTwitterFormattingStrategy(IUrlShortener urlShortener) { if (urlShortener == null) throw new ArgumentNullException("urlShortener"); this.urlShortener = urlShortener; }
/// <summary> /// Initializes a new instance of the <see cref="BlogController" /> class. /// </summary> /// <param name="blogRepository">The blog post repository.</param> /// <param name="commentRepository">The Disqus comment repository</param> /// <param name="urlShortener">The URL shortener</param> /// <param name="socialManager">The social network manager used to get sharing URLs</param> public BlogController(IBlogRepository blogRepository, IDisqusCommentRepository commentRepository, IUrlShortener urlShortener, ISocialManager socialManager) { _blogRepository = blogRepository; _commentRepository = commentRepository; _urlShortener = urlShortener; _socialManager = socialManager; }
public GoogleUrlShortenerTests() { var shortener = new GoogleUrlShortener(); this.shortener = shortener; this.messageRecorder = HttpMessageHandlerRecorder.CreatePlayback(typeof(GoogleUrlShortenerTests)); shortener.HttpClient = new HttpClient(this.messageRecorder); }
/// <summary> /// Initializes a new instance of the <see cref="BlogController" /> class. /// </summary> /// <param name="blogRepository">The blog post repository.</param> /// <param name="commentRepository">The Disqus comment repository</param> /// <param name="urlShortener">The URL shortener</param> /// <param name="socialManager">The social network manager used to get sharing URLs</param> /// <param name="siteConfig">Site configuration</param> public BlogController(IBlogRepository blogRepository, IDisqusCommentRepository commentRepository, IUrlShortener urlShortener, ISocialManager socialManager, ISiteConfiguration siteConfig) { _blogRepository = blogRepository; _commentRepository = commentRepository; _urlShortener = urlShortener; _socialManager = socialManager; _siteConfig = siteConfig; _profiler = MiniProfiler.Current; }
public UrlService(IUrlRecordRepository urlRecordRepository, IShortUrlSettings shortUrlSettings, IUrlShortener urlShortener) { Check.If(urlRecordRepository).IsNotNull(); Check.If(shortUrlSettings).IsNotNull(); Check.If(urlShortener).IsNotNull(); _urlRecordRepository = urlRecordRepository; _shortUrlSettings = shortUrlSettings; _urlShortener = urlShortener; }
public ShortUrlController( IUrlShortener urlShortener, IBlogRepository blogRepository, IUrlRepository urlRepository ) { _urlShortener = urlShortener; _blogRepository = blogRepository; _urlRepository = urlRepository; }
public ShortUrlController( IUrlShortener urlShortener, IBlogRepository blogRepository, IUrlRepository urlRepository, IBackgroundTaskQueue taskQueue ) { _urlShortener = urlShortener; _blogRepository = blogRepository; _urlRepository = urlRepository; _taskQueue = taskQueue; }
public BotServices( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener, IQueryStatisticsStore queryStatisticsStore, IAutocompleter autocompleter) { if (store == null) { throw new ArgumentNullException("store"); } if (priceStore == null) { throw new ArgumentNullException("priceStore"); } if (commandParser == null) { throw new ArgumentNullException("commandParser"); } if (httpClient == null) { throw new ArgumentNullException("httpClient"); } if (urlShortener == null) { throw new ArgumentNullException("urlShortener"); } if (queryStatisticsStore == null) { throw new ArgumentNullException("queryStatisticsStore"); } if (autocompleter == null) { throw new ArgumentNullException("autocompleter"); } this.mStore = store; this.mPriceStore = priceStore; this.mCommandParser = commandParser; this.mHttpClient = httpClient; this.mUrlShortener = urlShortener; this.mQueryStatisticsStore = queryStatisticsStore; this.mAutocompleter = autocompleter; }
public LoadAllVideos(IYouTubeReader youTubeReader, ISettings settings, SourceDataRepository sourceDataRepository, IUrlShortener urlShortener, ILogger <LoadAllVideos> logger, TelemetryClient telemetryClient) { _settings = settings; _sourceDataRepository = sourceDataRepository; _urlShortener = urlShortener; _youTubeReader = youTubeReader; _logger = logger; _telemetryClient = telemetryClient; }
public RedditTopCommentPlugin( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener) : base( store, priceStore, commandParser, httpClient, urlShortener) { }
public LoadAllPosts(IJsonFeedReader jsonFeedReader, ISettings settings, SourceDataRepository sourceDataRepository, IUrlShortener urlShortener, ILogger <LoadAllPosts> logger, TelemetryClient telemetryClient) { _settings = settings; _sourceDataRepository = sourceDataRepository; _urlShortener = urlShortener; _jsonFeedReader = jsonFeedReader; _logger = logger; _telemetryClient = telemetryClient; }
public TappedOutFormatCheckPlugin( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener, BotConfig config ) : base( store, priceStore, commandParser, httpClient, urlShortener, config) { }
public GetRandomCardByDescriptionPlugin( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener, BotConfig config ) : base( store, priceStore, commandParser, httpClient, urlShortener, config) { }
public SearchPlugin( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener, BotConfig config ) : base( store, priceStore, commandParser, httpClient, urlShortener, config) { }
public PluginBase( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener, BotConfig config) { if (store == null) { throw new ArgumentNullException("store"); } if (priceStore == null) { throw new ArgumentNullException("priceStore"); } if (commandParser == null) { throw new ArgumentNullException("commandParser"); } if (httpClient == null) { throw new ArgumentNullException("httpClient"); } if (urlShortener == null) { throw new ArgumentNullException("urlShortener"); } if (config == null) { throw new ArgumentNullException("config"); } this.mStore = store; this.mPriceStore = priceStore; this.mCommandParser = commandParser; this.mHttpClient = httpClient; this.mUrlShortener = urlShortener; this.mBotConfig = config; }
public LoadNewVideos(IYouTubeReader youTubeReader, ISettings settings, ConfigurationRepository configurationRepository, SourceDataRepository sourceDataRepository, IUrlShortener urlShortener, IEventPublisher eventPublisher, ILogger <LoadNewVideos> logger, TelemetryClient telemetryClient) { _youTubeReader = youTubeReader; _settings = settings; _configurationRepository = configurationRepository; _sourceDataRepository = sourceDataRepository; _urlShortener = urlShortener; _eventPublisher = eventPublisher; _logger = logger; _telemetryClient = telemetryClient; }
public CheckFeedForUpdates(ISyndicationFeedReader syndicationFeedReader, ISettings settings, ConfigurationRepository configurationRepository, SourceDataRepository sourceDataRepository, IUrlShortener urlShortener, IEventPublisher eventPublisher, ILogger <CheckFeedForUpdates> logger, TelemetryClient telemetryClient) { _syndicationFeedReader = syndicationFeedReader; _settings = settings; _configurationRepository = configurationRepository; _sourceDataRepository = sourceDataRepository; _urlShortener = urlShortener; _eventPublisher = eventPublisher; _logger = logger; _telemetryClient = telemetryClient; }
public MainViewModel(IUrlShortener urlShortener) { _urlShortener = urlShortener; ShortenCommand = new RelayCommand(() => { try { IsLoading = true; Shorten(); } catch (Exception) { IsLoading = false; throw; } }); }
public MainViewModel(IUrlShortener urlShortener) { _urlShortener = urlShortener; ShortenCommand = new RelayCommand(() => { try { IsLoading = true; Shorten(); } catch(Exception) { IsLoading = false; throw; } }); }
public WolframAlphaPlugin( IMtgStore store, ICardPriceStore priceStore, ICommandParser commandParser, IHttpClient httpClient, IUrlShortener urlShortener, BotConfig config) : base( store, priceStore, commandParser, httpClient, urlShortener, config) { string configFile = Path.Combine(Environment.CurrentDirectory, "Wolfram.ini"); string appId = LoadConfig(configFile); this.mWolframAlpha = new WolframAlpha(appId); this.mWolframAlpha.ScanTimeout = cScanTimeout; }
public UrlManagement(IUrlShortener shortener) { _shortener = shortener; _storage = new Dictionary <string, Url>(); }
public bool TryFind(Credential credential, out IUrlShortener shortener) { if (AvailableShorteners == null) AvailableShorteners = _composeUrlShorteners(); shortener = null; IUrlShortener newShortener = AvailableShorteners.Any() ? AvailableShorteners.SingleOrDefault( b => b.Protocol.Matches(credential.Protocol)) : null; if (newShortener == null) return false; shortener = CompositionManager.Get<IUrlShortener>(newShortener.GetType()); if (shortener == null) return false; shortener.Credentials = credential; return true; }
/// <summary> /// Initializes a new instance of the <see cref="SocialController" /> class. /// </summary> /// <param name="socialManager">The social manager.</param> /// <param name="blogRepository">The blog repository.</param> /// <param name="urlShortener">The URL shortener.</param> public SocialController(ISocialManager socialManager, IBlogRepository blogRepository, IUrlShortener urlShortener) { _socialManager = socialManager; _blogRepository = blogRepository; _urlShortener = urlShortener; }
public HomeController(ILogger <HomeController> logger, IUrlShortener urlShortener) { _logger = logger; _urlShortener = urlShortener; }
public UrlShortenerController() { urlShortener = new UrlShortenerImp(); }
/// <summary> /// Initializes a new instance of the <see cref="PostsApiController" /> class. /// </summary> /// <param name="blogRepository">The blog repository.</param> /// <param name="urlShortener">The URL shortener.</param> public PostsApiController(IBlogRepository blogRepository, IUrlShortener urlShortener) { _blogRepository = blogRepository; _urlShortener = urlShortener; }
/// <summary> /// Instantiates a new <see cref="UrlShortenerApiController" />. /// </summary> /// <param name="urlShortener">The URL shortener to be used for operations.</param> /// <remarks>Needed for unit testing, though DependencyInjection + IoC patterns would be best and eliminate parameterless ctor.</remarks> internal UrlShortenerApiController(IUrlShortener urlShortener) { this.urlShortener = urlShortener; }
public void SetDefaultShortener(IUrlShortener shortener) { DefaultShortener = shortener; }
public PlainTextParser(IUrlShortener shortener) { this._shortener = shortener; }
public static void RegisterShortener(IUrlShortener shortener) { shorteners.Add(shortener); }
public LinksController(ApplicationDbContext dbContext, IUrlShortener urlShortener) { _dbContext = dbContext; _urlShortener = urlShortener; }
public void Setup() { var mock = new Mock<IUrlShortener>(); mock.Setup(x => x.Short(It.IsAny<string>())).Returns("http://kcy.me/abcde").Verifiable(); urlShortener = mock.Object; }
public ParseUrlController(IUrlShortener urlShortner) { _urlShortener = urlShortner; }
public DetailController(IUrlShortener urlShortener) { _urlShortener = urlShortener; }
public CreateController(IUrlShortener urlShortener) { _urlShortener = urlShortener; }
public UrlController(IUrlStorage <Domain.Entities.PunyUrl> storage, IUrlShortener shortener) { this.storage = storage; this.shortener = shortener; }
public void Setup() { var credentials = Token.ReadFromRessource(GetType().Assembly, "twitter.urlshortener.tests.bitly.credentials.txt"); sut = new UrlShortener(credentials.Key, credentials.Secret); }
public PostHandler(ILinkRepository repository, IUrlShortener urlShortener) { _repository = repository; _urlShortener = urlShortener; }