isFriendsWith(user) method added to User
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 24 Nov 2016 23:08:26 +0000 (00:08 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Thu, 24 Nov 2016 23:08:26 +0000 (00:08 +0100)
TDD/src/main/java/org/craftedsw/tripservicekata/user/User.java
TDD/src/test/java/org/craftedsw/tripservicekata/user/UserShould.java

index c0442ff..d038fe8 100644 (file)
@@ -26,4 +26,8 @@ public class User {
                return trips;\r
        }\r
 \r
+       public boolean isFriendsWith(User anotherUser) {\r
+               return friends.contains(anotherUser);\r
+       }\r
+\r
 }\r
index 28b2a37..dfe2aee 100644 (file)
@@ -1,5 +1,31 @@
 package org.craftedsw.tripservicekata.user;
 
-public class UserTest {
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
 
+import org.craftedsw.tripservicekata.UserBuilder;
+import org.junit.Test;
+
+public class UserShould {
+
+       private static final User JOHN = new User();
+       private static final User PAUL = new User();
+
+       @Test public void
+       inform_when_users_are_not_friends() {
+               User user = UserBuilder.aUser()
+                                               .friendsWith(JOHN)
+                                               .build();
+               
+               assertThat(user.isFriendsWith(PAUL), is(false));
+       }
+       
+       @Test public void
+       inform_when_users_are_friends() {
+               User user = UserBuilder.aUser()
+                               .friendsWith(JOHN, PAUL)
+                               .build();
+               
+               assertThat(user.isFriendsWith(PAUL), is(true));
+       }
 }