|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TestStatusData | Line # 34 | 12 | 0% | 4 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (4) | |||
| Result | |||
|
0.3125
|
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testHashcode
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testHashcode
|
1 PASS | |
|
0.3125
|
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testEquals
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testEquals
|
1 PASS | |
|
0.25
|
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testValueOf
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testValueOf
|
1 PASS | |
|
0.125
|
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testToString
org.perfectjpattern.core.behavioral.observer.data.TestStatusData.testToString
|
1 PASS | |
| 1 | //---------------------------------------------------------------------- | |
| 2 | // | |
| 3 | // PerfectJPattern: "Design patterns are good but components are better!" | |
| 4 | // TestStatusData.java Copyright (c) 2009 Giovanni Azua Garcia | |
| 5 | // bravegag@hotmail.com | |
| 6 | // | |
| 7 | // This program is free software; you can redistribute it and/or | |
| 8 | // modify it under the terms of the GNU General Public License | |
| 9 | // as published by the Free Software Foundation; either version 3 | |
| 10 | // of the License, or (at your option) any later version. | |
| 11 | // | |
| 12 | // This program is distributed in the hope that it will be useful, | |
| 13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | // GNU General Public License for more details. | |
| 16 | // | |
| 17 | // You should have received a copy of the GNU General Public License | |
| 18 | // along with this program; if not, see <http://www.gnu.org/licenses/>. | |
| 19 | // | |
| 20 | //---------------------------------------------------------------------- | |
| 21 | package org.perfectjpattern.core.behavioral.observer.data; | |
| 22 | ||
| 23 | import junit.framework.*; | |
| 24 | ||
| 25 | /** | |
| 26 | * Test Suite for <code>StatusData</code> implementation. | |
| 27 | * | |
| 28 | * @see StatusData | |
| 29 | * | |
| 30 | * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a> | |
| 31 | * @version $Revision: 1.0 $ $Date: Jun 23, 2007 1:15:16 AM $ | |
| 32 | */ | |
| 33 | public final | |
| 34 | class TestStatusData | |
| 35 | extends TestCase | |
| 36 | { | |
| 37 | //------------------------------------------------------------------------ | |
| 38 | // public | |
| 39 | //------------------------------------------------------------------------ | |
| 40 | 1 |
public void |
| 41 | testValueOf() | |
| 42 | { | |
| 43 | 1 | StatusData myInstanceOne = new StatusData(Status.STARTED, |
| 44 | "There was a time"); | |
| 45 | 1 | StatusData myInstanceTwo = new StatusData(myInstanceOne); |
| 46 | ||
| 47 | 1 | assertEquals("valueOf() implemented incorrectly", myInstanceOne, |
| 48 | myInstanceTwo); | |
| 49 | } | |
| 50 | ||
| 51 | //------------------------------------------------------------------------ | |
| 52 | 1 |
public void |
| 53 | testEquals() | |
| 54 | { | |
| 55 | 1 | assertEquals("equals() implemented incorrectly", StatusData.STARTED, |
| 56 | new StatusData(Status.STARTED, "Task has started.")); | |
| 57 | ||
| 58 | 1 | assertFalse("equals() implemented incorrectly", |
| 59 | StatusData.STARTED.equals(ProgressData.STARTED)); | |
| 60 | ||
| 61 | 1 | assertFalse("equals() implemented incorrectly", |
| 62 | StatusData.STARTED.equals(null)); | |
| 63 | ||
| 64 | 1 | assertTrue("equals() implemented incorrectly", |
| 65 | !StatusData.STARTED.equals(StatusData.COMPLETED)); | |
| 66 | } | |
| 67 | ||
| 68 | //------------------------------------------------------------------------ | |
| 69 | 1 |
public void |
| 70 | testHashcode() | |
| 71 | { | |
| 72 | // same hash code => equals true | |
| 73 | 1 | assertTrue("hashCode() implemented incorrectly", |
| 74 | StatusData.STARTED.hashCode() == StatusData.STARTED.hashCode() && | |
| 75 | StatusData.STARTED.equals(StatusData.STARTED)); | |
| 76 | ||
| 77 | 1 | StatusData myData = |
| 78 | new StatusData(Status.STARTED, "Task has started."); | |
| 79 | ||
| 80 | // different hash code may still hold equals true | |
| 81 | 1 | assertTrue("hashCode() implemented incorrectly", |
| 82 | StatusData.STARTED.hashCode() == myData.hashCode() && | |
| 83 | StatusData.STARTED.equals(myData)); | |
| 84 | ||
| 85 | // equals false => different hash code | |
| 86 | 1 | assertTrue("hashCode() implemented incorrectly", |
| 87 | !StatusData.COMPLETED.equals(myData) && | |
| 88 | StatusData.COMPLETED.hashCode() != myData.hashCode()); | |
| 89 | } | |
| 90 | ||
| 91 | //------------------------------------------------------------------------ | |
| 92 | 1 |
public void |
| 93 | testToString() | |
| 94 | { | |
| 95 | 1 | assertEquals("toString() implemented incorrectly", |
| 96 | StatusData.STARTED.toString(), | |
| 97 | "StatusData(Status='Started', " + | |
| 98 | "Message='Task has started.')"); | |
| 99 | } | |
| 100 | } | |
|
||||||||||||