Skip to content
Browse files

End of episode 152

  • Loading branch information...
1 parent 54ce1eb commit 74163f8911f38c0d3dc5c28a578fce36cedbdb6a @jamesshore committed Dec 12, 2011
View
4 src/com/jamesshore/finances/ui/_ApplicationFrameTest.java
@@ -162,7 +162,9 @@ public boolean assertTrue() {
@Test
public void saveAsDialogShouldTellApplicationModelToSave() {
- // todo: delete me? finish me?
+ __ApplicationModelSpy mockModel = new __ApplicationModelSpy();
+ // do something that pushes the save button (sort of)
+ assertTrue("applicationModel should be told to save", "/example/pathname", mockModel.saveCalledWith);
}
abstract class AsynchronousAssertion {
View
32 src/com/jamesshore/finances/ui/_ConfigurationPanelTest.java
@@ -1,7 +1,6 @@
package com.jamesshore.finances.ui;
import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
import java.awt.*;
import javax.swing.*;
import net.miginfocom.swing.*;
@@ -61,18 +60,16 @@ public void fieldsInitializeToModelValue() {
@Test
public void startingBalanceFieldUpdatesApplicationModel() {
- ApplicationModel mockModel = mock(ApplicationModel.class);
+ __ApplicationModelSpy mockModel = new __ApplicationModelSpy();
panel = new ConfigurationPanel(mockModel);
startingBalanceField().setText("668");
- // verify(mockModel).setStartingBalance(ValidDollars.create(668));
- // assertEquals("applicationModel should be updated", ValidDollars.create(668),
- // mockModel.setStartingBalanceCalledWith);
+ assertEquals("applicationModel should be updated", ValidDollars.create(668), mockModel.setStartingBalanceCalledWith);
}
@Test
public void costBasisFieldUpdatesApplicationModel() {
- MockApplicationModel mockModel = new MockApplicationModel();
+ __ApplicationModelSpy mockModel = new __ApplicationModelSpy();
panel = new ConfigurationPanel(mockModel);
costBasisField().setText("670");
@@ -81,33 +78,12 @@ public void costBasisFieldUpdatesApplicationModel() {
@Test
public void yearlySpendingFieldUpdatesApplicationModel() {
- MockApplicationModel mockModel = new MockApplicationModel();
+ __ApplicationModelSpy mockModel = new __ApplicationModelSpy();
panel = new ConfigurationPanel(mockModel);
yearlySpendingField().setText("672");
assertEquals("applicationModel should be updated", ValidDollars.create(672), mockModel.setYearlySpendingCalledWith);
}
- private static class MockApplicationModel extends ApplicationModel {
- public Dollars setStartingBalanceCalledWith;
- public Dollars setStartingCostBasisCalledWith;
- public Dollars setYearlySpendingCalledWith;
-
- @Override
- public void setStartingBalance(Dollars startingBalance) {
- setStartingBalanceCalledWith = startingBalance;
- }
-
- @Override
- public void setStartingCostBasis(Dollars startingCostBasis) {
- setStartingCostBasisCalledWith = startingCostBasis;
- }
-
- @Override
- public void setYearlySpending(Dollars yearlySpending) {
- setYearlySpendingCalledWith = yearlySpending;
- }
- }
-
}
View
24 src/com/jamesshore/finances/ui/__ApplicationModelSpy.java
@@ -0,0 +1,24 @@
+package com.jamesshore.finances.ui;
+
+import com.jamesshore.finances.domain.*;
+
+public class __ApplicationModelSpy extends ApplicationModel {
+ public Dollars setStartingBalanceCalledWith;
+ public Dollars setStartingCostBasisCalledWith;
+ public Dollars setYearlySpendingCalledWith;
+
+ @Override
+ public void setStartingBalance(Dollars startingBalance) {
+ setStartingBalanceCalledWith = startingBalance;
+ }
+
+ @Override
+ public void setStartingCostBasis(Dollars startingCostBasis) {
+ setStartingCostBasisCalledWith = startingCostBasis;
+ }
+
+ @Override
+ public void setYearlySpending(Dollars yearlySpending) {
+ setYearlySpendingCalledWith = yearlySpending;
+ }
+}

0 comments on commit 74163f8

Please sign in to comment.
Something went wrong with that request. Please try again.