public async Task Iniciar_SemFuncaoPorArquivo_EntradaAquecida() { try { new FileService().RegisterService(); } catch (ServicoJaRegistradoException) { } var FS = ServiceLocator.Get <IFileService>(); var microondas = new Microondas(); var tempo = new TimeSpan(0, 0, 2); var potencia = 2; var entrada = "teste"; FS.Salvar(FS.GetExePath("arquivo.txt"), entrada); var funcao = new FuncaoMicroondas(potencia, tempo); await microondas.Iniciar(funcao, FS.GetExePath("arquivo.txt")); var arqValor = FS.Carregar(FS.GetExePath("arquivo.txt")); Assert.AreEqual(arqValor, entrada + "...."); }
public void ValidarEntrada_ComArquivo_Sucesso() { try { new FileService().RegisterService(); } catch (ServicoJaRegistradoException) { } var FS = ServiceLocator.Get <IFileService>(); var potencia = 3; var tempo = new TimeSpan(0, 0, 12); var nome = "teste"; var instrucao = "instrucao test"; var caractere = '@'; var alimento = "porco"; FS.Salvar(FS.GetExePath("arquivo.txt"), alimento); var funcao = new FuncaoMicroondas(potencia, tempo, nome, instrucao, caractere, alimento); var arquivoAlimento = FS.Carregar(FS.GetExePath("arquivo.txt")); var exceptionGerado = false; try { funcao.ValidarEntrada(arquivoAlimento); } catch (Exception) { exceptionGerado = true; } Assert.IsFalse(exceptionGerado); }
public void Iniciar(FuncaoMicroondas funcaoMicroondas) { try { var entrada = Entrada.Trim(); IsLigado = true; microondas.Iniciar(funcaoMicroondas, entrada); } catch (Exception e) { ExibirErro(e.Message); } }
public async Task Iniciar_ComFuncao_EntradaAquecidaAsync() { var microondas = new Microondas(); var tempo = new TimeSpan(0, 0, 2); var potencia = 3; var entrada = "teste"; var funcao = new FuncaoMicroondas(potencia, tempo); await microondas.Iniciar(funcao, entrada); Assert.AreEqual(microondas.EntradaAquecida, entrada + "......"); }
public void Iniciar() { try { var tempo = GetTempo(); var potencia = GetPotencia(); var funcao = new FuncaoMicroondas(potencia, tempo); Iniciar(funcao); } catch (Exception e) { ExibirErro(e.Message); } }
public void ValidarEntrada_SemArquivo_Falha() { var potencia = 3; var tempo = new TimeSpan(0, 0, 12); var nome = "teste"; var instrucao = "instrucao test"; var caractere = '@'; var alimento = "porco"; var funcao = new FuncaoMicroondas(potencia, tempo, nome, instrucao, caractere, alimento); var exceptionGerado = false; try { funcao.ValidarEntrada("123", false); } catch (Exception) { exceptionGerado = true; } Assert.IsTrue(exceptionGerado); }
public void ValidarTempo_MaiorQueDoisMinutos_GerarException() { var potencia = 3; var tempo = new TimeSpan(0, 2, 1); var nome = "teste"; var instrucao = "instrucao test"; var caractere = '@'; var alimento = "porco"; var funcao = new FuncaoMicroondas(potencia, tempo, nome, instrucao, caractere, alimento); var exceptionGerado = false; try { funcao.Validar(); } catch (Exception) { exceptionGerado = true; } Assert.IsTrue(exceptionGerado); }
public void ValidarPotencia_IgualZero_GerarException() { var potencia = 0; var tempo = new TimeSpan(0, 0, 12); var nome = "teste"; var instrucao = "instrucao test"; var caractere = '@'; var alimento = "porco"; var funcao = new FuncaoMicroondas(potencia, tempo, nome, instrucao, caractere, alimento); var exceptionGerado = false; try { funcao.Validar(); } catch (Exception) { exceptionGerado = true; } Assert.IsTrue(exceptionGerado); }