public async Task Execute_ReturnsTranslation_WhenEntitiesHaveTextAndTargetLanguage() { var testEntities = new List <LuisEntity> { new LuisEntity { Score = 1, Type = "Dictionary.Text", Name = "Hello" }, new LuisEntity { Score = 1, Type = "Dictionary.TargetLanguage", Name = "French" } }; var settingsMock = new Mock <ISettings>(); settingsMock.Setup(x => x.TranslateApiKey) .Returns(Config["GoogleTarnslateApiKey"]); var translateIntent = new TranslateIntent(settingsMock.Object); var result = await translateIntent.Execute(testEntities); Assert.IsNotNull(result); Assert.IsFalse(string.IsNullOrEmpty(result.Message)); Assert.AreEqual(result.Message, "Bonjour"); }
public async Task Execute_ReturnsRecognitionResultWithErrorMessage_WhenTargetLanguageIsEmpty() { var testTranslateEntities = new List <LuisEntity> { new LuisEntity { Name = "Hello", Type = "Dictionary.Text", Score = 0 }, new LuisEntity { Name = string.Empty, Type = "Dictionary.TargetLanguage", Score = 0 } }; var settingsMock = CreateSettingsMock(); var translateIntent = new TranslateIntent(settingsMock.Object); var result = await translateIntent.Execute(testTranslateEntities); Assert.IsNotNull(result); Assert.AreEqual(result.Message, TranslateIntentErrorMessage); }