/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package tmcsim.client.cadclientgui.screens;

import java.util.Vector;
import junit.framework.TestCase;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/**
 *
 * @author jdalbey
 */
public class LoginTest extends TestCase {
    
    public LoginTest(String testName) {
        super(testName);
    }
    
    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }
    
    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    /**
     * Test of readNamesFile method, of class Login.
     */
    public void testReadNamesFile() throws IOException {
        System.out.println("readNamesFile");
        File file = File.createTempFile("temp", null);
        PrintWriter writer = null;
        try {
            writer = new PrintWriter(file);
            writer.println(" ");
            writer.println("  Trainee, Jose  ");
            writer.close();
        } catch(Exception e)
        {e.printStackTrace();}

        String studentNamesFile = file.getAbsolutePath();
        Vector<String> expResult = new Vector<String>();
        expResult.add("Trainee, Jose");
        Vector<String> result = Login.readNamesFile(studentNamesFile);
        assertEquals(expResult, result);
    }

    /**
     * Test of reverseLastFirst method, of class Login.
     */
    public void testReverseLastFirst() {
        System.out.println("reverseLastFirst");
        String result = Login.reverseLastFirst("Trainee, Jose");
        assertEquals("Jose Trainee", result);
        result = Login.reverseLastFirst("  Trainee,   Jose  ");
        assertEquals("Jose Trainee", result);
        result = Login.reverseLastFirst("  Smith ,  Bob  ");
        assertEquals("Bob Smith", result);
        result = Login.reverseLastFirst("Nocomma Case");
        assertEquals("Nocomma Case", result);
        result = Login.reverseLastFirst("  ");
        assertEquals("  ", result);
    }
    
}
