示例#1
0
 @Test
 public void shouldStringAddedToStringBuffer() throws StateException {
   LoggerState state = new LoggerStringState(printer, decorator);
   state.toBuffer("Kek");
   state.printBuffer();
   verify(decorator).decorate("STRING", "Kek");
 }
示例#2
0
 @Test
 public void shouldCharAddedToCharStateBuffer() throws StateException {
   LoggerState state = new LoggerCharState(printer, decorator);
   state.toBuffer('a');
   state.printBuffer();
   verify(decorator).decorate("CHAR", "a");
 }
示例#3
0
 @Test
 public void shouldObjectAddedToObjectStateBuffer() throws StateException {
   LoggerState state = new LoggerObjState(printer, decorator);
   Object obj = new Object();
   state.toBuffer(obj);
   state.printBuffer();
   verify(decorator).decorate("OBJ", obj.toString());
 }
示例#4
0
 @Test
 public void shouldSumStateSummingNumbers() throws StateException {
   LoggerState state = new LoggerSumState(printer, decorator);
   state.toBuffer(50);
   state.toBuffer(22);
   state.toBuffer(-2);
   state.printBuffer();
   verify(decorator).decorate("INT", "70");
 }
示例#5
0
 @Test
 public void shouldStringStateCallPrintWhenNextStringNotEqualsToPrevious() throws StateException {
   LoggerState state = new LoggerStringState(printer, decorator);
   state.toBuffer("First");
   state.toBuffer("Second");
   state.printBuffer();
   verify(decorator).decorate("STRING", "First");
   verify(decorator).decorate("STRING", "Second");
 }
示例#6
0
 @Test
 public void shouldBooleanAddedToBooleanBuffer() throws StateException {
   LoggerState state = new LoggerBoolState(printer, decorator);
   state.toBuffer(true);
   state.printBuffer();
   state.toBuffer(false);
   state.printBuffer();
   verify(decorator).decorate("BOOL", "true");
   verify(decorator).decorate("BOOL", "false");
 }
示例#7
0
 @Test
 public void shouldSumStatePreventOverflowing() throws StateException {
   LoggerState state = new LoggerSumState(printer, decorator);
   state.toBuffer(Integer.MAX_VALUE);
   state.toBuffer(10);
   state.toBuffer(Integer.MIN_VALUE);
   state.toBuffer(-100);
   state.printBuffer();
   verify(decorator).decorate("INT", Integer.MAX_VALUE + "");
   verify(decorator).decorate("INT", 10 + Integer.MIN_VALUE + "");
   verify(decorator).decorate("INT", "-100");
 }