Andrei Branza - converted indents to spaces test classes
This commit is contained in:
parent
54851a8042
commit
93020dc544
@ -7,17 +7,17 @@ import static org.junit.Assert.assertNotEquals;
|
|||||||
|
|
||||||
public class DeepCloningTest {
|
public class DeepCloningTest {
|
||||||
|
|
||||||
Person alex = new Person("Alex", "Jones", new Address("Main Street", "Main City"));
|
Person alex = new Person("Alex", "Jones", new Address("Main Street", "Main City"));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingDeepCopy_thenReferencesAreNotTheSame()
|
public void whenUsingDeepCopy_thenReferencesAreNotTheSame()
|
||||||
{
|
{
|
||||||
Person constructorCopyOfAlex = new Person(alex);
|
Person constructorCopyOfAlex = new Person(alex);
|
||||||
|
|
||||||
assertEquals(alex, constructorCopyOfAlex);
|
assertEquals(alex, constructorCopyOfAlex);
|
||||||
|
|
||||||
alex.setAddress(new Address("Unknown Street", "Unknown City"));
|
alex.setAddress(new Address("Unknown Street", "Unknown City"));
|
||||||
|
|
||||||
assertNotEquals(alex.getAddress(), constructorCopyOfAlex.getAddress());
|
assertNotEquals(alex.getAddress(), constructorCopyOfAlex.getAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,17 +5,17 @@ import static org.junit.Assert.*;
|
|||||||
|
|
||||||
public class ShallowCloningTest {
|
public class ShallowCloningTest {
|
||||||
|
|
||||||
Person alex = new Person("Alex", "Jones", new Address("Main Street", "Main City"));
|
Person alex = new Person("Alex", "Jones", new Address("Main Street", "Main City"));
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void whenUsingShallowCopy_ThenReferencesAreTheSame()
|
public void whenUsingShallowCopy_ThenReferencesAreTheSame()
|
||||||
{
|
{
|
||||||
Person shallowCopyOfAlex = alex.clone();
|
Person shallowCopyOfAlex = alex.clone();
|
||||||
|
|
||||||
assertEquals(alex, shallowCopyOfAlex);
|
assertEquals(alex, shallowCopyOfAlex);
|
||||||
|
|
||||||
alex.getAddress().setCityName("Unknown City");
|
alex.getAddress().setCityName("Unknown City");
|
||||||
|
|
||||||
assertEquals(alex.getAddress(), shallowCopyOfAlex.getAddress());
|
assertEquals(alex.getAddress(), shallowCopyOfAlex.getAddress());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user