File tree Expand file tree Collapse file tree
org.moreunit.test/test/org/moreunit/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ package org .moreunit .util ;
2+
3+ import static org .mockito .Mockito .mock ;
4+ import static org .mockito .Mockito .when ;
5+ import static org .junit .Assert .assertTrue ;
6+ import static org .junit .Assert .assertEquals ;
7+
8+ import org .eclipse .jdt .core .IMethod ;
9+ import org .junit .Before ;
10+ import org .junit .Test ;
11+
12+ public class MethodComparatorTest
13+ {
14+ private MethodComparator methodComparator ;
15+
16+ @ Before
17+ public void setUp ()
18+ {
19+ methodComparator = new MethodComparator ();
20+ }
21+
22+ @ Test
23+ public void should_order_methods_by_element_name ()
24+ {
25+ IMethod methodA = mock (IMethod .class );
26+ when (methodA .getElementName ()).thenReturn ("methodA" );
27+
28+ IMethod methodB = mock (IMethod .class );
29+ when (methodB .getElementName ()).thenReturn ("methodB" );
30+
31+ assertTrue (methodComparator .compare (methodA , methodB ) < 0 );
32+ assertTrue (methodComparator .compare (methodB , methodA ) > 0 );
33+ }
34+
35+ @ Test
36+ public void should_return_zero_for_equal_methods ()
37+ {
38+ IMethod methodA = mock (IMethod .class );
39+ when (methodA .getElementName ()).thenReturn ("methodA" );
40+
41+ IMethod methodB = mock (IMethod .class );
42+ when (methodB .getElementName ()).thenReturn ("methodA" );
43+
44+ assertEquals (0 , methodComparator .compare (methodA , methodB ));
45+ }
46+ }
Original file line number Diff line number Diff line change 1+ package org .moreunit .util ;
2+
3+ import static org .mockito .Mockito .mock ;
4+ import static org .mockito .Mockito .when ;
5+ import static org .junit .Assert .assertTrue ;
6+ import static org .junit .Assert .assertEquals ;
7+
8+ import org .eclipse .jdt .core .IType ;
9+ import org .junit .Before ;
10+ import org .junit .Test ;
11+
12+ public class TypeComparatorTest
13+ {
14+ private TypeComparator typeComparator ;
15+
16+ @ Before
17+ public void setUp ()
18+ {
19+ typeComparator = new TypeComparator ();
20+ }
21+
22+ @ Test
23+ public void should_order_types_by_fully_qualified_name ()
24+ {
25+ IType typeA = mock (IType .class );
26+ when (typeA .getFullyQualifiedName ()).thenReturn ("org.example.AClass" );
27+
28+ IType typeB = mock (IType .class );
29+ when (typeB .getFullyQualifiedName ()).thenReturn ("org.example.BClass" );
30+
31+ assertTrue (typeComparator .compare (typeA , typeB ) < 0 );
32+ assertTrue (typeComparator .compare (typeB , typeA ) > 0 );
33+ }
34+
35+ @ Test
36+ public void should_return_zero_for_equal_types ()
37+ {
38+ IType typeA = mock (IType .class );
39+ when (typeA .getFullyQualifiedName ()).thenReturn ("org.example.AClass" );
40+
41+ IType typeB = mock (IType .class );
42+ when (typeB .getFullyQualifiedName ()).thenReturn ("org.example.AClass" );
43+
44+ assertEquals (0 , typeComparator .compare (typeA , typeB ));
45+ }
46+ }
You can’t perform that action at this time.
0 commit comments