Skip to content

Commit

Permalink
first defaultstep tests now pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich Apodaca committed Jun 28, 2009
1 parent 6d43268 commit 265e25a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 17 deletions.
55 changes: 39 additions & 16 deletions src/com/metamolecular/mx/test/DefaultStepTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,45 +43,68 @@ public class DefaultStepTest extends TestCase
@Override
protected void setUp() throws Exception
{
step = null;
atom = mock(Atom.class);
bond = mock(Bond.class);
step = new DefaultStep(atom);
}

public void testItHasAtom()
{
atomWithOneBond();
assertEquals(atom, step.getAtom());
}

public void testItHasNoAtomsInPathToStart()
{
Bond[] bonds = new Bond[]
{
bond
};

when(atom.getBonds()).thenReturn(bonds);
assertEquals(bonds, atom.getBonds());
// assertEquals(0, step.getPath().size());
atomWithOneBond();
assertEquals(0, step.getPath().size());
}

public void testItHasAtom()
public void testItHasNextBondWhenAtomHasOneBond()
{
assertEquals(atom, step.getAtom());
atomWithOneBond();
assertTrue(step.hasNextBond());
}

public void testItReturnsNextBondWhenAtomHasOneBond()
{
atomWithOneBond();
assertEquals(bond, step.nextBond());
}

public void testItHasNextBondInInitialState()
public void testItDoesntHaveNextBondWhenAtomHasNoBonds()
{
atomWithNoBonds();
assertFalse(step.hasNextBond());
}

public void testItCreatesANewStepFromNextBond()
{
atomWithOneBond();

Bond next = step.nextBond();

assertNotNull(step.nextStep(next));
}

private void atomWithNoBonds()
{
Bond[] bonds = new Bond[]
{
bond
};

when(atom.getBonds()).thenReturn(bonds);
assertTrue(step.hasNextBond());
step = new DefaultStep(atom);
}

public void testItReturnsNextBondInInitialState()
private void atomWithOneBond()
{
Bond[] bonds = new Bond[]
{
bond
};

when(atom.getBonds()).thenReturn(bonds);
assertEquals(bond, step.nextBond());
step = new DefaultStep(atom);
}
}
7 changes: 6 additions & 1 deletion src/com/metamolecular/mx/walk/DefaultStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public DefaultStep(Atom focus)

loadBonds();
}

private DefaultStep(Step step, Bond bond)
{

}

public Atom getAtom()
{
Expand Down Expand Up @@ -83,7 +88,7 @@ public Bond nextBond()

public Step nextStep(Bond bond)
{
throw new UnsupportedOperationException("Not supported yet.");
return new DefaultStep(this, bond);
}

public boolean closesRingWith(Bond bond)
Expand Down

0 comments on commit 265e25a

Please sign in to comment.