public HttpResponseMessage Get(int?id) { var response = Request.CreateResponse(); FunctionConfiguration calcFunction = db.FunctionConfiguration.Find(id); if (calcFunction == null) { List <CategoryViewModel> json = repo.GetConfig(null); response.Content = new StringContent(JsonConvert.SerializeObject(json)); } else { if (calcFunction.Configuration == null) { HttpContext.Current.Cache.Remove("config"); List <CategoryViewModel> json = repo.GetConfig(null); response.Content = new StringContent(JsonConvert.SerializeObject(json)); } else { response.Content = new StringContent(calcFunction.Configuration); } } return(response); }
public void GetConfig_GetSameConfigTwice_ReturnsSameConfig() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config1 = configRepository.GetConfig("myConfig"); Assert.IsTrue(configRepository.Configurations.Contains("myConfig")); IConfig config2 = configRepository.GetConfig("myConfig"); Assert.AreEqual(config1, config2); }
public void GetConfig_CanLoadConfigsFromMultipleThreads() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(false, true); var configRepository = new ConfigRepository(configLoader); const int maxThreads = 10; Exception ex = null; IConfig config = null; var getConfigCompletedEvent = new ManualResetEvent(false); for(int i = 0; i < maxThreads; i++) { int remainingThreads = i; ThreadPool.QueueUserWorkItem(s => { try { config = configRepository.GetConfig(configKey, false); if(Interlocked.Decrement(ref remainingThreads) == 0) { getConfigCompletedEvent.Set(); } } catch(Exception innerEx) { getConfigCompletedEvent.Set(); ex = innerEx; throw; } }); } getConfigCompletedEvent.WaitOne(); getConfigCompletedEvent.Close(); Assert.IsNotNull(config); Assert.IsNull(ex); }
public void GetConfig_LoadCurrentConfigThatDoesNotExistAndSupressExceptions_ReturnsNull() { var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(true); Assert.IsNull(config); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadConfigForCustomAssembly_ReturnsConfigWithCorrectSystemConfigKey() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(assembly); Assert.AreEqual(assembly.GetName().Name, config.ConfigKey); }
public void GetConfig_LoadConfigForCustomAssemblyDoesNotExist_ThrowsConfigurationException() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws<ConfigurationException>(() => configRepository.GetConfig(assembly)); Assert.AreEqual(assembly.GetName().Name, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_CanLoadConfigsFromMultipleThreads() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(false, true); var configRepository = new ConfigRepository(configLoader); const int maxThreads = 10; Exception ex = null; IConfig config = null; var getConfigCompletedEvent = new ManualResetEvent(false); for (int i = 0; i < maxThreads; i++) { int remainingThreads = i; ThreadPool.QueueUserWorkItem(s => { try { config = configRepository.GetConfig(configKey, false); if (Interlocked.Decrement(ref remainingThreads) == 0) { getConfigCompletedEvent.Set(); } } catch (Exception innerEx) { getConfigCompletedEvent.Set(); ex = innerEx; throw; } }); } getConfigCompletedEvent.WaitOne(); getConfigCompletedEvent.Close(); Assert.IsNotNull(config); Assert.IsNull(ex); }
protected override void OnResume() { base.OnResume(); nomusuario.Click += delegate { StopItems(); }; tipo.Click += delegate { StopItems(); }; velocidad.Click += delegate { StopItems(); }; activacion.Click += delegate { StopItems(); }; loginService = new LoginService(); userService = new UserService(); try { client = loginService.Connect(); if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } } catch (Exception ex) { this.FinishAffinity(); } database = new SQLiteRepository(); userRepository = new UserRepository(database); configRepository = new ConfigRepository(database); errorText = new ErrorText(); configuracion = configRepository.GetConfig(); speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); toSpeech = new TextToSpeech(this, this); gestureDetector = new GestureDetector(this); }
public void GetConfig_LoadCurrentConfigThatDoesNotExist_ThrowsConfigurationException() { var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws <ConfigurationException>(() => configRepository.GetConfig()); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadCurrentConfig_ReturnsConfigWithCorrectSystemConfigKey() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", config.ConfigKey); }
public TooltipDefinition[] GetFileSpecificTooltipDefinitions(string fileFullPath) { //return new TooltipDefinition[1] { // new TooltipDefinition { Description="asd", Input="asd" } // }; var config = configRepository.GetConfig(); return(config.ConfigItems.Where(ci => ci.IsFileMatchingPattern(fileFullPath)).SelectMany(ci => ci.TooltipDefinitions).ToArray()); }
public void GetConfig_LoadConfigForCustomAssemblyDoesNotExist_ThrowsConfigurationException() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws <ConfigurationException>(() => configRepository.GetConfig(assembly)); Assert.AreEqual(assembly.GetName().Name, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadCurrentConfigThatDoesNotExistAndSupressExceptions_ReturnsNull() { var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(true); Assert.IsNull(config); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadConfigForCustomAssembly_ReturnsConfigWithCorrectSystemConfigKey() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(assembly); Assert.AreEqual(assembly.GetName().Name, config.ConfigKey); }
public void GetConfig_LoadConfigForCustomConfigDoesNotExist_ThrowsConfigurationException() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws <ConfigurationException>(() => configRepository.GetConfig(configKey)); Assert.AreEqual(configKey, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadConfigForCustomConfig_ReturnsConfigWithCorrectSystemConfigKey() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(configKey); Assert.AreEqual(configKey, config.ConfigKey); }
public void GetConfig_LoadConfigForCustomAssemblyDoesNotExistAndSupressExceptions_ReturnsNull() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(assembly, true); Assert.IsNull(config); Assert.AreEqual(assembly.GetName().Name, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadConfigForCustomConfigDoesNotExistAndSupressExceptions_ReturnsNull() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(configKey, true); Assert.IsNull(config); Assert.AreEqual(configKey, configLoader.ConfigKeysLoaded[0]); }
private void InitializeConfigItems() { var config = configRepository.GetConfig(); var configItems = config.ConfigItems.Select(i => new ConfigItemViewModel(i.FilePattern, i.IsRegex, Map(i.TooltipDefinitions))); Items = new ObservableCollection <ConfigItemViewModel>(configItems); AllConfigs.ItemsSource = Items; if (Items.Any()) { AllConfigs.SelectedItem = Items[0]; } }
public HttpResponseMessage Get(int?id) { var response = Request.CreateResponse(); CalcRelease calcConfiguration = db.CalcRelease.Find(id); if (calcConfiguration == null) { List <CategoryViewModel> json = repo.GetConfig(null); response.Content = new StringContent(JsonConvert.SerializeObject(json)); } else { if (calcConfiguration.Configuration == null) { List <CategoryViewModel> json = repo.GetConfig(null); response.Content = new StringContent(JsonConvert.SerializeObject(json)); } else { response.Content = new StringContent(calcConfiguration.Configuration); } } return(response); }
public JsonResult GetAll() { ConfigRepository SucRep = new ConfigRepository(); try { return(Json(SucRep.GetConfig(), JsonRequestBehavior.AllowGet)); } catch (Exception ex) { List <Config> list = new List <Config>(); Config obj = new Config(); obj.Accion = 0; obj.Mensaje = ex.Message.ToString(); list.Add(obj); return(Json(list, JsonRequestBehavior.AllowGet)); } }
private void Initialize() { try { m_configProperties.WriteFullFence(m_configRepository.GetConfig()); } catch (Exception ex) { logger.Warn( string.Format("Init Apollo Local Config failed - namespace: {0}, reason: {1}.", m_namespace, ExceptionUtil.GetDetailMessage(ex))); } finally { //register the change listener no matter config repository is working or not //so that whenever config repository is recovered, config could get changed m_configRepository.AddChangeListener(this); } }
public void GetConfig() { SQLiteRepository con = new SQLiteRepository(); con.CreateDatabase(); ConfigRepository configRepository = new ConfigRepository(con); Config c = new Config() { Phone = "34676681420", Voz = false, Velocidad = (float)0.5 }; using (var connection = con.GetConnection()) { configRepository.InsertConfig(c); var result = configRepository.GetConfig(); Assert.AreEqual(false, result.Voz); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Main); this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn); database = new SQLiteRepository(); configRepo = new ConfigRepository(database); loginService = new LoginService(); errorText = new ErrorText(); FakeSessionDelete = new FakeSessionDelete(); configuracion = configRepo.GetConfig(); b = FindViewById <ImageButton>(Resource.Id.Enviar); b2 = FindViewById <ImageButton>(Resource.Id.Leer); b3 = FindViewById <ImageButton>(Resource.Id.Contactos); b4 = FindViewById <ImageButton>(Resource.Id.Configuracion); logout = FindViewById <Button>(Resource.Id.logout); try { client = loginService.Connect(); } catch (Exception ex) { this.FinishAffinity(); } if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } service = new Intent(this, typeof(ReceiveService)); if (!IsMyServiceRunning(service)) { StartService(service); } SetVisible(true); }
protected override void OnResume() { base.OnResume(); database = new SQLiteRepository(); contactRepository = new ContactRepository(database); configRepository = new ConfigRepository(database); configuracion = configRepository.GetConfig(); errorText = new ErrorText(); speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); gestureDetector = new GestureDetector(this); toSpeech = new TextToSpeech(this, this); }
private bool TrySyncFromUpstream() { if (m_upstream == null) { return(false); } try { Properties properties = m_upstream.GetConfig(); UpdateFileProperties(properties); return(true); } catch (Exception ex) { logger.Warn( string.Format("Sync config from upstream repository {0} failed, reason: {1}", m_upstream.GetType(), ExceptionUtil.GetDetailMessage(ex))); } return(false); }
protected override void OnResume() { base.OnResume(); configRepo = new ConfigRepository(database); configuracion = configRepo.GetConfig(); service = new Intent(this, typeof(ReceiveService)); if (!IsMyServiceRunning(service)) { StartService(service); } speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); gestureDetector = new GestureDetector(this); toSpeech = new TextToSpeech(this, this); }
public void GetConfig_LoadConfigForCustomConfigDoesNotExist_ThrowsConfigurationException() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws<ConfigurationException>(() => configRepository.GetConfig(configKey)); Assert.AreEqual(configKey, configLoader.ConfigKeysLoaded[0]); }
protected override void OnResume() { base.OnResume(); configRepo = new ConfigRepository(database); configuracion = configRepo.GetConfig(); if (listaContactos.Count > 0) { textToSpeak = "Sus contactos bloqueados son: "; for (int i = 0; i < listaContactos.Count; i++) { if (listaContactos.Count == 1) { textToSpeak += $"{listaContactos[i]}. "; } else { if (i == (listaContactos.Count - 1)) { textToSpeak += $"y {listaContactos[i]}. "; } else { textToSpeak += $"{listaContactos[i]}, "; } } } } else { textToSpeak = "No tienes contactos bloqueados. "; } textToSpeak += "¿Quiere bloquear un contacto, desbloquear un contacto, no hacer nada o volver atrás?"; try { client = loginService.Connect(); if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } } catch (Exception ex) { this.FinishAffinity(); } speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); gestureDetector = new GestureDetector(this); toSpeech = new TextToSpeech(this, this); }
protected override void OnResume() { base.OnResume(); configRepository = new ConfigRepository(database); configuracion = configRepository.GetConfig(); loginService = new LoginService(); messageService = new MessageService(); errorText = new ErrorText(); try { client = loginService.Connect(); if (client.IsUserAuthorized()) { usuario = client.Session.TLUser; } } catch (Exception ex) { this.FinishAffinity(); } try { _chats = messageRepository.GetMessagesByPhoneWithoutSeen(extra); contact = contactRepository.GetContactByPhone(extra); messageRepository.MarkMessagesAsRead(extra); var total = _chats.Sum(x => x.Mensaje.Length); if (_chats.Count > 0) { textToSpeak = $"Los mensajes nuevos de {contact.FirstName} {contact.LastName} son: "; if (total < 3900) { for (int i = 0; i < _chats.Count; i++) { int j = i + 1; if (i == _chats.Count - 1) { textToSpeak += $" y {j.ToString()} {_chats[i].Mensaje}"; } else { textToSpeak += $"{j.ToString()} {_chats[i].Mensaje}, "; } } textToSpeak += ". ¿Quiere responder?"; accion = "responder"; } else { LeerMensajesSinLeer(); } } else { textToSpeak = "¿Quiere leer desde una fecha, buscar por un mensaje, no hacer nada o volver atrás?"; accion = "leer"; } } catch (Exception ex) { textToSpeak = "Ha ocurrido un error al acceder a la base de datos. ¿Quiere leer desde una fecha, buscar por un mensaje, no hacer nada o volver atrás?"; accion = "leer"; } speechReco = SpeechRecognizer.CreateSpeechRecognizer(this.ApplicationContext); speechReco.SetRecognitionListener(this); intentReco = new Intent(RecognizerIntent.ActionRecognizeSpeech); intentReco.PutExtra(RecognizerIntent.ExtraLanguagePreference, "es"); intentReco.PutExtra(RecognizerIntent.ExtraCallingPackage, this.PackageName); intentReco.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelWebSearch); intentReco.PutExtra(RecognizerIntent.ExtraMaxResults, 1); gestureDetector = new GestureDetector(this); toSpeech = new TextToSpeech(this, this); }
public void GetConfig_LoadConfigForCustomConfig_ReturnsConfigWithCorrectSystemConfigKey() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(configKey); Assert.AreEqual(configKey, config.ConfigKey); }
public void GetConfig_LoadConfigForCustomAssemblyDoesNotExistAndSupressExceptions_ReturnsNull() { Assembly assembly = typeof(FakeItEasy.A).Assembly; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(assembly, true); Assert.IsNull(config); Assert.AreEqual(assembly.GetName().Name, configLoader.ConfigKeysLoaded[0]); }
public void OnResults(Bundle results) { Log.Info(LOG_TAG, "onResults"); IEnumerable <string> matches = results.GetStringArrayList(SpeechRecognizer.ResultsRecognition); int count = 0; countSpeech++; configuracion = configRepository.GetConfig(); foreach (string result in matches) { count++; try { if (count == 1) { if (countSpeech == 1) { if (result.ToLower().Contains("usuario")) { accion = "usuario"; try { user = userRepository.GetUser(); textToSpeak = user.Username != null ? $"Su nombre de usuario es {user.Username}" : "No tiene nombre de usuario"; textToSpeak += ". ¿Quiere modificarlo?"; } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al acceder a la base de datos. Por favor, inténtelo más tarde. " + "¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura o " + "la activación de la voz, no hacer nada o volver atrás?"; } toSpeech = new TextToSpeech(this, this); } else if (result.ToLower().Contains("tipo")) { accion = "tipo"; string voz = toSpeech.Voice != null ? toSpeech.Voice.Name : "la voz por defecto"; textToSpeak = $"La voz actual es: {voz}. "; listVoice = toSpeech.Voices; if (listVoice != null && listVoice.Count > 1) { textToSpeak += "Las voces actualmente instaladas son: "; int contador = 0; foreach (var item in listVoice) { contador++; if (contador == listVoice.Count) { textToSpeak += $"y {item.Name}. "; } else { textToSpeak += $"{item.Name}, "; } } textToSpeak += "Diga el nombre de la voz a cambiar o diga cancelar"; } else { countSpeech = 0; textToSpeak += "No tiene más voces instaladas. ¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura o " + "la activación de la voz, no hacer nada o volver atrás?"; } toSpeech = new TextToSpeech(this, this); } else if (result.ToLower().Contains("velocidad")) { accion = "velocidad"; string velocidad = configuracion.Velocidad == 1.0 ? "normal" : configuracion.Velocidad == 0.5 ? "lenta" : configuracion.Velocidad == 0.0 ? "muy lenta" : configuracion.Velocidad == 1.5 ? "rápida" : configuracion.Velocidad == 2 ? "muy rápida" : "super rápida"; textToSpeak = $"La velocidad de lectura es {velocidad}. ¿Quiere aumentar la velocidad de lectura, reducirla o cancelar?"; toSpeech = new TextToSpeech(this, this); } else if (result.ToLower().Contains("activación") || result.ToLower().Contains("activacion")) { accion = "activar"; string voz = configuracion.Voz ? "activada" : "desactivada"; string act = configuracion.Voz ? "desactivarla" : "activarla"; textToSpeak = $"La voz está {voz} .¿Quiere {act}?"; toSpeech = new TextToSpeech(this, this); } else if (result.ToLower().Contains("atras") || result.ToLower().Contains("atrás") || result.ToLower().Contains("volver")) { StopItems(); StartActivity(typeof(MainActivity)); } else if (result.ToLower().Contains("nada")) { } else { countSpeech = 0; textToSpeak = "Lo siento, no ha dicho una opción válida. ¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } } else if (countSpeech == 2) { if (accion == "usuario" && (result.ToLower().Contains("si") || result.ToLower().Contains("sí"))) { textToSpeak = "¿Qué nombre de usuario quiere?"; toSpeech = new TextToSpeech(this, this); } else if ((accion == "usuario" || accion == "activar") && result.ToLower().Contains("no")) { countSpeech = 0; textToSpeak = "¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura o " + "la activación de la voz, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } else if (accion == "velocidad") { countSpeech = 0; if (result.ToLower().Contains("cancelar")) { } else if (result.ToLower().Contains("aumentar")) { if (configuracion.Velocidad == 2.5) { textToSpeak = "No se puede aumentar más la velocidad de lectura."; } else { try { configuracion.Velocidad = configuracion.Velocidad + (float)0.5; configRepository.UpdateConfig(configuracion); textToSpeak = "Velocidad de lectura aumentada."; } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al acceder a la base de datos. Por favor, inténtelo más tarde."; } } } else if (result.ToLower().Contains("reducir")) { if (configuracion.Velocidad == 0.0) { countSpeech = 0; textToSpeak = "No se puede reducir más la velocidad de lectura."; } else { try { configuracion.Velocidad = configuracion.Velocidad - (float)0.5; configRepository.UpdateConfig(configuracion); textToSpeak = "Velocidad de lectura reducida."; } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al acceder a la base de datos. Por favor, inténtelo más tarde."; } } } configuracion = configRepository.GetConfig(); textToSpeak += " ¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } else if (accion == "tipo") { if (result.ToLower().Contains("cancelar")) { countSpeech = 0; textToSpeak += "¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } else { bool exist = false; foreach (var item in listVoice) { if (item.Name == result) { v = item; exist = true; break; } } if (exist) { try { countSpeech = 0; configuracion.TipoVoz = result; configRepository.UpdateConfig(configuracion); toSpeech.SetVoice(v); textToSpeak = "Voz modificada. ¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al acceder a la base de datos. Por favor, inténtelo más tarde. ¿Quiere modificar" + " su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; } } else { countSpeech = 1; textToSpeak = "No existe ese tipo de voz. Por favor, diga otro nombre de voz o cancelar"; } toSpeech = new TextToSpeech(this, this); } } else if (accion == "activar" && (result.ToLower().Contains("si") || result.ToLower().Contains("sí"))) { try { countSpeech = 0; configuracion.Voz = !configuracion.Voz; string texto = configuracion.Voz ? "activada" : "desactivada"; configRepository.UpdateConfig(configuracion); textToSpeak = $"Voz {texto}. ¿Quiere modificar su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al acceder a la base de datos. Por favor, inténtelo más tarde. ¿Quiere modificar" + " su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; } toSpeech = new TextToSpeech(this, this); } } else if (countSpeech == 3) { if (accion == "usuario") { if (result.ToLower().Contains("cancelar")) { countSpeech = 0; textToSpeak = "¿Quiere modificar tu nombre de usuario, el tipo de voz, la velocidad de lectura o " + "la activación de la voz, no hacer nada o volver atrás?"; toSpeech = new TextToSpeech(this, this); } else { try { bool valido = userService.CheckUsername(client, result); if (valido) { try { userService.UpdateUsername(client, result, userRepository); Vibrator vibrator = (Vibrator)this.GetSystemService(Context.VibratorService); vibrator.Vibrate(500); countSpeech = 0; textToSpeak = $"Su nombre de usuario ha sido modificado correctamente a {result}. ¿Quiere modificar tu nombre de usuario, " + "el tipo de voz, la velocidad de lectura o la activación de la voz, no hacer nada o volver atrás?"; } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al modificar su nombre de usuario. Por favor, inténtelo más tarde. ¿Quiere modificar" + " su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; } toSpeech = new TextToSpeech(this, this); } else { countSpeech = 2; textToSpeak = "El nombre de usuario no es válido. Por favor, diga otro nombre de usuario o cancelar"; toSpeech = new TextToSpeech(this, this); } } catch (Exception ex) { countSpeech = 0; textToSpeak = "Ha ocurrido un error al modificar su nombre de usuario. Por favor, inténtelo más tarde. ¿Quiere modificar" + " su nombre de usuario, el tipo de voz, la velocidad de lectura " + "o la activación de la voz, no hacer nada o volver atrás?"; } } } } } } catch (Exception ex) { } } }
public void GetConfig_LoadConfigForCustomConfigDoesNotExistAndSupressExceptions_ReturnsNull() { const string configKey = "MyCustomConfig"; var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(configKey, true); Assert.IsNull(config); Assert.AreEqual(configKey, configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadCurrentConfigThatDoesNotExist_ThrowsConfigurationException() { var configLoader = new FakeLoader(true); var configRepository = new ConfigRepository(configLoader); Assert.Throws<ConfigurationException>(() => configRepository.GetConfig()); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", configLoader.ConfigKeysLoaded[0]); }
public void GetConfig_LoadCurrentConfig_ReturnsConfigWithCorrectSystemConfigKey() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config = configRepository.GetConfig(); Assert.AreEqual("nJupiter.Configuration.Tests.Unit", config.ConfigKey); }
public void GetConfig_GetSameConfigTwice_ReturnsSameConfig() { var configLoader = new FakeLoader(); var configRepository = new ConfigRepository(configLoader); IConfig config1 = configRepository.GetConfig("myConfig"); Assert.IsTrue(configRepository.Configurations.Contains("myConfig")); IConfig config2 = configRepository.GetConfig("myConfig"); Assert.AreEqual(config1, config2); }