Package br.com.caelum.stella.formatter

Source Code of br.com.caelum.stella.formatter.TituloEleitoralFormatterTest

package br.com.caelum.stella.formatter;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Before;
import org.junit.Test;

import br.com.caelum.stella.format.Formatter;
import br.com.caelum.stella.format.TituloEleitoralFormatter;

public class TituloEleitoralFormatterTest {

    private Formatter formatter;

    @Before
    public void before() {
        formatter = new TituloEleitoralFormatter();
    }

    @Test
    public void testFormat() {
        String unfotmatedValue = "133968200302";
        String formatedValue = formatter.format(unfotmatedValue);
        assertEquals(formatedValue, "1339682003/02");
    }

    @Test
    public void testUnformat() {
        String fotmatedValue = "1339682003/02";
        String unformatedValue = formatter.unformat(fotmatedValue);
        assertEquals(unformatedValue, "133968200302");
    }

    @Test
  public void shouldVerifyIfAValueIsFormattedOrNot() throws Exception {
    assertTrue(formatter.isFormatted("1339682003/02"));
    assertFalse(formatter.isFormatted("133968200302"));
    assertFalse(formatter.isFormatted("1339682003/0x"));
  }

    @Test
  public void shouldVerifyIfAValueCanBeFormattedOrNot() throws Exception {
    assertFalse(formatter.canBeFormatted("1339682003/02"));
    assertTrue(formatter.canBeFormatted("133968200302"));
    assertFalse(formatter.canBeFormatted("1339682003/0x"));
  }
}
TOP

Related Classes of br.com.caelum.stella.formatter.TituloEleitoralFormatterTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.