1+ /*
2+ * To change this license header, choose License Headers in Project Properties.
3+ * To change this template file, choose Tools | Templates
4+ * and open the template in the editor.
5+ */
6+
7+ package com .linux .designpatterns .flyweight .improvedletter ;
8+
9+ import org .junit .Before ;
10+ import org .junit .Test ;
11+ import static org .hamcrest .MatcherAssert .assertThat ;
12+ import static org .junit .Assert .*;
13+ import static org .hamcrest .CoreMatchers .*;
14+
15+ /**
16+ *
17+ * @author Guruprasad Kulkarni <guru@linux.com>
18+ */
19+ public class WordProcessorTest {
20+
21+ private WordProcessor wp ;
22+
23+ public WordProcessorTest () {
24+ }
25+
26+ @ Before
27+ public void setUp () {
28+ this .wp = new WordProcessor ();
29+ }
30+
31+ /**
32+ * Test of add method, of class WordProcessor.
33+ */
34+ @ Test
35+ public void testAdd_Letter () {
36+ System .out .println ("add" );
37+ //Arrange
38+ String expected = "This is a very normal String. It has nothing special in it!" ;
39+ for (char c : expected .toCharArray ()) {
40+ this .wp .add (c );
41+ }
42+
43+ //Act
44+ String actual = wp .showText ();
45+
46+ //Assert
47+ assertThat (actual , is (equalTo (expected )));
48+ }
49+
50+ // /**
51+ // * Test of add method, of class WordProcessor.
52+ // */
53+ // @Test
54+ // public void testAdd_char() {
55+ // System.out.println("add");
56+ // char c = ' ';
57+ // WordProcessor instance = new WordProcessor();
58+ // WordProcessor expResult = null;
59+ // WordProcessor result = instance.add(c);
60+ // assertEquals(expResult, result);
61+ // // TODO review the generated test code and remove the default call to fail.
62+ // fail("The test case is a prototype.");
63+ // }
64+ //
65+ // /**
66+ // * Test of showText method, of class WordProcessor.
67+ // */
68+ // @Test
69+ // public void testShowText() {
70+ // System.out.println("showText");
71+ // WordProcessor instance = new WordProcessor();
72+ // String expResult = "";
73+ // String result = instance.showText();
74+ // assertEquals(expResult, result);
75+ // // TODO review the generated test code and remove the default call to fail.
76+ // fail("The test case is a prototype.");
77+ // }
78+
79+ }
0 commit comments