package white.box.tester.tests;

import org.testng.annotations.Test;
import white.box.tester.model.ContactData;
import white.box.tester.model.Contacts;

import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.testng.Assert.assertEquals;

/**
 * Created by Max on 9/19/2016.
 */
public class ContactModificationTests extends TestBase {

  @Test

  public void testContactModification() {

    if (app.db().contacts().size() == 0){
      app.goTo().gotoHomePage();
      app.getContactHelper().createUser(new ContactData().withFirstname("Test23").withLastname("Test113").
              withAddress("Test4443").withHomephone("5343"));

    }

      app.goTo().gotoHomePage();
    Contacts before = app.db().contacts();
    ContactData modifiedContact = before.iterator().next();
    ContactData contact = new ContactData().withId(modifiedContact.getId()).withFirstname("Test123").withLastname("Test1212").
            withAddress("Test14443").withHomephone("15343");

    app.getContactHelper().modify(contact);

    app.goTo().gotoHomePage();
    Contacts after = app.db().contacts();
    assertEquals(after.size(), before.size());
    assertThat(after, equalTo(before.withOut(modifiedContact).withAdded(contact)));
  }


}

@@ -668,30 +668,8 @@
 43%22)
-.withHomephone(%225343%22)
 );%0A%0A
@@ -886,16 +886,29 @@
 getId())
+%0A            
 .withFir
@@ -920,24 +920,37 @@
 e(%22Test123%22)
+%0A            
 .withLastnam
@@ -962,17 +962,16 @@
 st1212%22)
-.
 %0A       
@@ -967,32 +967,33 @@
 2%22)%0A            
+.
 withAddress(%22Tes
@@ -1009,23 +1009,43 @@
 with
-Homephone(%221534
+Mobile(%22234235%22).withEmail1(%22test12
 3%22);
@@ -1090,17 +1090,16 @@
 ntact);%0A
-%0A
     app.
@@ -1113,32 +1113,97 @@
 gotoHomePage();%0A
+    assertEquals(app.getContactHelper().count(), before.size());%0A
     Contacts aft

Update 7.4 full. Homework_17