public void EditandoUmJogo() { BaseDeDados dbXml = new BaseDeDados(); Jogo jogoEditado = new Jogo("Super Zelda 2", "Aventura", 50, 21, "locado"); dbXml.AlterarCamposDoJogo(jogoEditado, "Super Zelda 2"); Jogo jogoEsperado = new Jogo("Super Zelda 2", "Aventura", 50, 21, "locado"); Jogo jogo = dbXml.GetJogo("Super Zelda 2"); Assert.AreEqual(jogo, jogoEsperado); }
public static void EditarJogo(string jogoASerAlterado) { BaseDeDados dbXml = new BaseDeDados(); bool rodando = true; string novoNome = ""; double preco = 0.0; string categoria = ""; string status = ""; int id = dbXml.nextID(); int respostaSeQuerMudarID = NAO; if (jogoASerAlterado != "") { while (rodando) { menuPrincipal.PedirNomeDoJogo(); novoNome = Console.ReadLine(); if(novoNome != "") { rodando = false; } else { menuPrincipal.ExceptionDigitarNome(); } } rodando = true; while (rodando) { try { menuPrincipal.PedirPreco(); preco = Convert.ToDouble(Console.ReadLine()); rodando = false; } catch (FormatException) { menuPrincipal.PedirParaDigitarValorDouble(); } } rodando = true; while (rodando) { menuPrincipal.PerguntarSeQuerMudarOId(); try { respostaSeQuerMudarID = Convert.ToInt32(Console.ReadLine()); if(respostaSeQuerMudarID == 1 || respostaSeQuerMudarID == 2) { rodando = false; } else { throw new FormatException(); } } catch (FormatException) { menuPrincipal.ExcepitionSeQuermudarID(); } } rodando = true; if (respostaSeQuerMudarID == SIM) { while (rodando) { menuPrincipal.PedirId(); try { id = Convert.ToInt32(Console.ReadLine()); rodando = false; } catch (FormatException) { Console.WriteLine("Você deve digitar um numero inteiro"); } } } else { id = dbXml.GetIdJogo(jogoASerAlterado); } rodando = true; while (rodando) { menuPrincipal.PedirCategoria(); categoria = Console.ReadLine(); if (categoria != "") { rodando = false; } else { menuPrincipal.ExceptionDigitarCategoria(); } } rodando = true; while (rodando) { menuPrincipal.PedirStatus(); status = Console.ReadLine(); if (status.ToLower() == "disponivel" || status.ToLower() == "locado") { rodando = false; } else { menuPrincipal.ExceptionStatus(); } } Jogo jogo = new Jogo(novoNome, categoria, preco, id,status); dbXml.AlterarCamposDoJogo(jogo, jogoASerAlterado); } }