public void NomesCompletosAgnomeTeste() { List <string> nomes = new List <string> { "João cabral DE melo Neto" }; string valorEsperado = "MELO NETO, João Cabral de"; NormasABNT abnt = new NormasABNT(nomes); List <Autor> autores = abnt.NomesCompletos(); Assert.AreEqual(valorEsperado, autores[0].ToString(), "Nome retornado incorreto!"); }
public void NomesCompletosTeste() { List <string> nomes = new List <string> { "Friedrich Wilhelm Nietzsche" }; string valorEsperado = "NIETZSCHE, Friedrich Wilhelm"; NormasABNT abnt = new NormasABNT(nomes); List <Autor> autores = abnt.NomesCompletos(); Assert.AreEqual(valorEsperado, autores[0].ToString(), "Nome retornado incorreto!"); }
public void NomesIncompletosTeste() { List <string> nomes = new List <string> { "GuiMaRaes" }; string valorEsperado = "GUIMARAES"; NormasABNT abnt = new NormasABNT(nomes); List <Autor> autores = abnt.NomesIncompletos(); Assert.AreEqual(valorEsperado, autores[0].ToString(), "Nome retornado incorreto!"); }
static void Main(string[] args) { Console.Write("Quantidade de nomes: "); int qtdNomes = 0; if (int.TryParse(Console.ReadLine(), out qtdNomes)) { try { List <string> nomes = new List <string>(); //Receber os nomes for (int i = 1; i <= qtdNomes; i++) { Console.Write(i + "º nome: "); nomes.Add(Console.ReadLine()); } //Instância das classes NormasABNT abnt = new NormasABNT(nomes); ProcessarReferencias _ref = new ProcessarReferencias(); //Processando os nomes e passando como parâmetro a norma utilizada List <Autor> Autores = _ref.ProcessarNomes(abnt); //Ordenando em ordem alfabética com Linq Autores.Sort((autor1, autor2) => autor1.Sobrenome.ToUpper().CompareTo(autor2.Sobrenome.ToUpper())); //Exibindo os nomes Console.WriteLine(); Autores.ForEach(autor => Console.WriteLine(autor.ToString())); } catch (Exception ex) { Console.WriteLine("Houve um erro ao processar os nomes. " + ex.Message); } } else { Console.WriteLine("Digite apenas números"); } Console.ReadKey(); }
public void OrganizarNomesTeste() { List <string> nomes = new List <string> { "SIlva", "Immanuel Kant", "Arthur Schopenhauer", "João cabral DE melo Neto" }; List <string> valorEsperado = new List <string> { "SILVA", "KANT, Immanuel", "SCHOPENHAUER, Arthur", "MELO NETO, João Cabral de" }; List <string> resultados = new List <string>(); NormasABNT abnt = new NormasABNT(nomes); List <Autor> autores = abnt.OrganizarNomes(); foreach (var autor in autores) { resultados.Add(autor.ToString()); } CollectionAssert.AreEqual(valorEsperado, resultados, "Lista de nomes incorreta!"); }