Ejemplo n.º 1
0
 public MainWindow(ActiveTranslatorConfiguration activeTranslatorConfiguration,
                   IApplicationConfiguration applicationConfiguration,
                   TranslatorBootstrapper translator)
 {
     this.activeTranslatorConfiguration = activeTranslatorConfiguration;
     this.applicationConfiguration      = applicationConfiguration;
     this.translator = translator;
 }
Ejemplo n.º 2
0
        public async Task When_Only_Google_Enabled()
        {
            const string detectedLanguage = "en";
            const string english          = "City";
            const string turkish          = "sehir";
            const string result           = "* sehir\r\n";

            var notifier         = A.Fake <INotifier>();
            var googleAnalytics  = A.Fake <IGoogleAnalyticsTracker>();
            var languageDetector = A.Fake <IGoogleLanguageDetector>();
            var resultOrganizer  = A.Fake <ResultOrganizer>();
            var translator       = A.Fake <ITranslator>();
            CancellationToken cancellationToken = CancellationToken.None;

            A.CallTo(() => languageDetector.DetectLanguage(english, A <CancellationToken> .Ignored))
            .Returns(detectedLanguage);
            A.CallTo(() => translator.Translate(A <TranslateRequest> .Ignored, cancellationToken))
            .Returns(new TranslateResult(true, turkish));
            A.CallTo(() => translator.Type).Returns(TranslatorType.Google);

            var activeTranslatorConfiguration = new ActiveTranslatorConfiguration();

            activeTranslatorConfiguration.AddTranslator(TranslatorType.Google);
            activeTranslatorConfiguration.Activate(TranslatorType.Google);

            var wireUp = new WireUp(
                builder =>
            {
                builder.AddInMemoryCollection(new[]
                {
                    new KeyValuePair <string, string>("ToLanguage", "Turkish"),
                    new KeyValuePair <string, string>("FromLanguage", "English")
                });
            }, services =>
            {
                services.RemoveAll <ITranslator>();
                services.AddTransient <IFinder, Finder>();
                services.AddTransient(sp => notifier);
                services.AddTransient(sp => googleAnalytics);
                services.AddTransient(sp => languageDetector);
                services.AddTransient(sp => activeTranslatorConfiguration);
                services.AddTransient(sp => resultOrganizer);
                services.AddSingleton(sp => translator);
            })
            {
                MessageHandler = GoogleMessageHandler()
            };

            var sut = wireUp.ServiceProvider.GetService <IFinder>();
            await sut.Find(english, cancellationToken);

            A.CallTo(() => notifier.AddNotification(english, ImageUrls.NotificationUrl, result))
            .MustHaveHappenedOnceExactly();
            A.CallTo(() => translator.Translate(A <TranslateRequest> .Ignored, A <CancellationToken> .Ignored))
            .MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 3
0
 public Finder(INotifier notifier,
               IGoogleLanguageDetector languageDetector,
               IGoogleAnalyticsService googleAnalytics,
               ActiveTranslatorConfiguration activeTranslatorConfiguration,
               IEnumerable <ITranslator> translators,
               IApplicationConfiguration applicationConfiguration,
               ResultOrganizer resultOrganizer)
 {
     this.notifier         = notifier;
     this.languageDetector = languageDetector;
     this.googleAnalytics  = googleAnalytics;
     this.activeTranslatorConfiguration = activeTranslatorConfiguration;
     this.translators = translators;
     this.applicationConfiguration = applicationConfiguration;
     this.resultOrganizer          = resultOrganizer;
 }
 public SesliSozlukTranslatorConfiguration(ActiveTranslatorConfiguration activeTranslatorConfiguration,
                                           IApplicationConfiguration applicationConfiguration) : base(activeTranslatorConfiguration,
                                                                                                      applicationConfiguration)
 {
 }
Ejemplo n.º 5
0
 public PromptTranslatorConfiguration(
     ActiveTranslatorConfiguration activeTranslatorConfiguration,
     IApplicationConfiguration applicationConfiguration) : base(activeTranslatorConfiguration,
                                                                applicationConfiguration)
 {
 }
 public TurengTranslatorConfiguration(ActiveTranslatorConfiguration activeTranslatorConfiguration,
                                      IApplicationConfiguration applicationConfiguration) : base(activeTranslatorConfiguration,
                                                                                                 applicationConfiguration)
 {
     this.applicationConfiguration = applicationConfiguration;
 }