1 package cintoo.messages.example; 2 3 import examples.UserContext; 4 import cintoo.messages.context.PackageContext; 5 import org.testng.annotations.*; 6 import org.testng.Assert; 7 8 public class TestUserContext { 9 private UserContext context; 10 11 @Configuration(beforeTestMethod = true) 12 public void setUp() { 13 context = new UserContext("testUser"); 14 } 15 16 @Test 17 public void testMatches() { 18 Assert.assertTrue( context.matches(new UserContext("testUser")), "UserContext matches equal UserContext"); 19 Assert.assertTrue( context.matches(context), "UserContext matches same UserContext"); 20 Assert.assertTrue( !(context.matches(PackageContext.string("testContext"))), "UserContext does not matches other Context"); 21 Assert.assertTrue( !(context.matches(new UserContext("otherTestUser"))), "UserContext does not match other UserContext"); 22 } 23 24 @Test 25 public void testCompareTo() { 26 Assert.assertEquals(context.compareTo("String"), 0, "CompareTo returns 0"); 27 Assert.assertEquals(context.compareTo(context), 0, "CompareTo returns 0"); 28 Assert.assertEquals(context.compareTo(new UserContext("otherUser")), 0, "CompareTo returns 0"); 29 } 30 31 } 32 | Popular Tags |