ecbfbaec30b2f4846357fb016f3208b693a48846
[WeStealzYourDataz.git] / test / uk / ac / ntu / n0521366 / wsyd / libs / WSYD_Member_Comparator_UserNameTest.java
1 /*
2  * The MIT License
3  *
4  * Copyright 2015 Eddie Berrisford-Lynch <n0521366@ntu.ac.uk>.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 package uk.ac.ntu.n0521366.wsyd.libs;
25
26 import org.junit.After;
27 import org.junit.AfterClass;
28 import org.junit.Before;
29 import org.junit.BeforeClass;
30 import org.junit.Test;
31 import static org.junit.Assert.*;
32
33 /**
34  *
35  * @author TJ <hacker@iam.tj>
36  */
37 public class WSYD_Member_Comparator_UserNameTest {
38     WSYD_Member_Comparator_UserName instance;
39     WSYD_Member member;
40     
41     public WSYD_Member_Comparator_UserNameTest() {
42     }
43     
44     @BeforeClass
45     public static void setUpClass() {
46     }
47     
48     @AfterClass
49     public static void tearDownClass() {
50     }
51     
52     @Before
53     public void setUp() {
54         instance = new WSYD_Member_Comparator_UserName();
55         member = new WSYD_Member();
56         member._userName = "Eddie";
57     }
58     
59     @After
60     public void tearDown() {
61     }
62
63     /**
64      * Test of compare method, of class WSYD_Member_Comparator_UserName.
65      */
66     @Test
67     public void testCompare() {
68         System.out.println(java.text.MessageFormat.format("{0}.compare(value, value)", instance.getClass().getName()));
69         WSYD_Member l = new WSYD_Member();
70         WSYD_Member m = new WSYD_Member();
71         WSYD_Member n = new WSYD_Member();
72         WSYD_Member o = new WSYD_Member();
73         l._userName = "Below";
74         m._userName = "Eddie";
75         n._userName = "Higher";
76         o._userName = "Fit";
77         assertEquals( 3, instance.compare(member, l));
78         assertEquals( 0, instance.compare(member, m));
79         assertEquals(-3, instance.compare(member, n));
80         assertEquals(-1, instance.compare(member, o));
81     }
82
83     @Test (expected=NullPointerException.class)    
84     public void testNPEuser1() {
85         System.out.println(java.text.MessageFormat.format("{0}.compare(null, value)", instance.getClass().getName()));
86         instance.compare(member, null);
87     }
88     
89     @Test (expected=NullPointerException.class)    
90     public void testNPEuser2() {
91         System.out.println(java.text.MessageFormat.format("{0}.compare(value, null)", instance.getClass().getName()));
92         instance.compare(null, member);
93     }
94     
95     @Test (expected=NullPointerException.class)
96     public void testNPEboth() {
97         System.out.println(java.text.MessageFormat.format("{0}.compare(null,null)", instance.getClass().getName()));
98         instance.compare(null, null);
99     }
100
101 }