Package com.codahale.shore.test

Source Code of com.codahale.shore.test.HelpCommandTest$A_Help_Command

package com.codahale.shore.test;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;

import java.io.ByteArrayOutputStream;

import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.runners.Enclosed;
import org.junit.runner.RunWith;

import com.codahale.shore.HelpCommand;

@RunWith(Enclosed.class)
public class HelpCommandTest {
  public static class A_Help_Command {
    private HelpCommand cmd;
    private ByteArrayOutputStream output;
   
    @Before
    public void setup() throws Exception {
      this.output = new ByteArrayOutputStream();
      this.cmd = new HelpCommand("Usage: woo", output);
    }
   
    @Test
    public void itHasText() throws Exception {
      assertThat(cmd.getText(), is("Usage: woo"));
    }
   
    @Test
    public void itHasAnOutputStream() throws Exception {
      assertThat((ByteArrayOutputStream) cmd.getOutputStream(), is(sameInstance(output)));
    }
   
    @Test
    public void itPrintsTheTextToTheOutputStream() throws Exception {
      cmd.run();
     
      assertThat(output.toString(), is(
        "Usage: woo" +
        "\n"
      ));
    }
  }
}
TOP

Related Classes of com.codahale.shore.test.HelpCommandTest$A_Help_Command

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.