mirror of
https://github.com/emilybache/GildedRose-Refactoring-Kata.git
synced 2025-12-12 04:12:13 +00:00
Converted to parametrized test; not as nice as it ought to be, but not exactly easy using OCUnit...
This commit is contained in:
parent
99a5861125
commit
aeb8c878d0
@ -2,17 +2,13 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="3432493f-5b19-44ab-868c-f539ff9f9548" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Tennis/TennisGame.h" afterPath="$PROJECT_DIR$/Tennis/TennisGame.h" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Tennis/TennisGame.m" afterPath="$PROJECT_DIR$/Tennis/TennisGame.m" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Tennis/TennisGame1.h" afterPath="$PROJECT_DIR$/Tennis/TennisGame1.h" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Tennis/TennisGame1.m" afterPath="$PROJECT_DIR$/Tennis/TennisGame1.m" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Tennis/TennisGame2.m" afterPath="$PROJECT_DIR$/Tennis/TennisGame2.m" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/Tennis/TennisGame3.m" afterPath="$PROJECT_DIR$/Tennis/TennisGame3.m" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/TennisTests/TennisTests.h" afterPath="$PROJECT_DIR$/TennisTests/TennisTests.h" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/TennisTests/TennisTests.m" afterPath="$PROJECT_DIR$/TennisTests/TennisTests.m" />
|
||||
</list>
|
||||
<ignored path="Tennis.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
<file path="/fragment.mm" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370012942444" ignored="false" />
|
||||
<file path="/TennisTests.m" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370018341630" ignored="false" />
|
||||
<file path="/TennisTests.m" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370023803720" ignored="false" />
|
||||
<file path="/fragment.m" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370014036256" ignored="false" />
|
||||
<file path="/TennisGame1.h" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370013500893" ignored="false" />
|
||||
<file path="/TennisGame2.h" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370013513152" ignored="false" />
|
||||
@ -24,6 +20,7 @@
|
||||
<file path="/TennisGame1.m" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370020207784" ignored="false" />
|
||||
<file path="/TennisGame.h" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370019947680" ignored="false" />
|
||||
<file path="/TennisGame2.m" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370021568226" ignored="false" />
|
||||
<file path="/LLDB" changelist="3432493f-5b19-44ab-868c-f539ff9f9548" time="1370023838835" ignored="false" />
|
||||
<option name="TRACKING_ENABLED" value="true" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -37,16 +34,16 @@
|
||||
<component name="DaemonCodeAnalyzer">
|
||||
<disable_hints />
|
||||
</component>
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="iphonesimulator_6.1_2" />
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="iphonesimulator_6.1_1" />
|
||||
<component name="FavoritesManager">
|
||||
<favorites_list name="Tennis" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf>
|
||||
<file leaf-file-name="TennisGame3.m" pinned="false" current="true" current-in-tab="true">
|
||||
<file leaf-file-name="TennisGame3.m" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/TennisGame3.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="50" column="8" selection-start="1203" selection-end="1203" vertical-scroll-proportion="1.2908778">
|
||||
<state line="19" column="1" selection-start="329" selection-end="329" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -61,10 +58,10 @@
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="TennisTests.m" pinned="false" current="false" current-in-tab="false">
|
||||
<file leaf-file-name="TennisTests.m" pinned="false" current="true" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/TennisTests/TennisTests.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="85" column="0" selection-start="2286" selection-end="2286" vertical-scroll-proportion="0.0">
|
||||
<state line="88" column="44" selection-start="2828" selection-end="2830" vertical-scroll-proportion="2.271945">
|
||||
<folding>
|
||||
<element signature="e#144#183#0" expanded="true" />
|
||||
</folding>
|
||||
@ -102,7 +99,7 @@
|
||||
<file leaf-file-name="TennisGame1.m" pinned="false" current="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/TennisGame1.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="14" column="1" selection-start="267" selection-end="267" vertical-scroll-proportion="0.0">
|
||||
<state line="18" column="0" selection-start="366" selection-end="366" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -156,13 +153,13 @@
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame2.h" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame3.h" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame.mm" />
|
||||
<option value="$PROJECT_DIR$/TennisTests/TennisTests.m" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame1.m" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame.h" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame1.h" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame.m" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame2.m" />
|
||||
<option value="$PROJECT_DIR$/Tennis/TennisGame3.m" />
|
||||
<option value="$PROJECT_DIR$/TennisTests/TennisTests.m" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -322,7 +319,7 @@
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39977974" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Run" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32929516" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.32929516" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
@ -392,7 +389,7 @@
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<option name="time" value="1" />
|
||||
<option name="time" value="2" />
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
@ -417,13 +414,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/TennisGame1.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="14" column="1" selection-start="267" selection-end="267" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/TennisGame.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="13" column="0" selection-start="254" selection-end="254" vertical-scroll-proportion="0.0">
|
||||
@ -445,15 +435,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/TennisTests/TennisTests.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="85" column="0" selection-start="2286" selection-end="2286" vertical-scroll-proportion="0.0">
|
||||
<folding>
|
||||
<element signature="e#144#183#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/ViewController.h">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="0" column="0" selection-start="0" selection-end="0" vertical-scroll-proportion="0.0">
|
||||
@ -463,11 +444,27 @@
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/TennisGame3.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="50" column="8" selection-start="1203" selection-end="1203" vertical-scroll-proportion="1.2908778">
|
||||
<state line="19" column="1" selection-start="329" selection-end="329" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/Tennis/TennisGame1.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="18" column="0" selection-start="366" selection-end="366" vertical-scroll-proportion="0.0">
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/TennisTests/TennisTests.m">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state line="88" column="44" selection-start="2828" selection-end="2830" vertical-scroll-proportion="2.271945">
|
||||
<folding>
|
||||
<element signature="e#144#183#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
</project>
|
||||
|
||||
|
||||
@ -10,4 +10,5 @@
|
||||
|
||||
@interface TennisTests : SenTestCase
|
||||
|
||||
- (id)initWithInvocation:(NSInvocation *)invocation scores:(NSArray *)scores;
|
||||
@end
|
||||
|
||||
@ -18,18 +18,15 @@
|
||||
NSString *expectedScore;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
// Set-up code here.
|
||||
}
|
||||
+ (id)defaultTestSuite {
|
||||
SenTestSuite *testSuite = [[SenTestSuite alloc] initWithName:NSStringFromClass(self)];
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
// Tear-down code here.
|
||||
|
||||
[super tearDown];
|
||||
NSArray *allScores = [self allScores];
|
||||
for (NSArray *scores in allScores) {
|
||||
[self addTestWithScores:scores toTestSuite:testSuite];
|
||||
}
|
||||
|
||||
return testSuite;
|
||||
}
|
||||
|
||||
+ (NSArray*)allScores {
|
||||
@ -75,6 +72,48 @@
|
||||
];
|
||||
}
|
||||
|
||||
+ (void)addTestWithScores:(NSArray *)scores toTestSuite:(SenTestSuite *)testSuite {
|
||||
NSArray *testInvocations = [self testInvocations];
|
||||
for (NSInvocation *testInvocation in testInvocations) {
|
||||
|
||||
// Create a new instance of our test case for each method found using the given set of parameters.
|
||||
SenTestCase *test = [[TennisTests alloc] initWithInvocation:testInvocation
|
||||
scores:scores];
|
||||
|
||||
// Add the new test instance to the suite. The OCUnit framework eventually executes the entire test suite.
|
||||
[testSuite addTest:test];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)name {
|
||||
return [NSString stringWithFormat:@"%@ (%d,%d,%@)", [super name], player1Score, player2Score, expectedScore];
|
||||
}
|
||||
|
||||
|
||||
- (id)initWithInvocation:(NSInvocation *)invocation scores:(NSArray *)scores {
|
||||
self = [super initWithInvocation:invocation];
|
||||
if (self) {
|
||||
player1Score = [scores[0] intValue];
|
||||
player2Score = [scores[1] intValue];
|
||||
expectedScore = scores[2];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
// Set-up code here.
|
||||
}
|
||||
|
||||
- (void)tearDown
|
||||
{
|
||||
// Tear-down code here.
|
||||
|
||||
[super tearDown];
|
||||
}
|
||||
|
||||
- (void)checkAllScoresForGame:(TennisGame *)game {
|
||||
int highestScore = MAX(player1Score, player2Score);
|
||||
for (int i = 0; i < highestScore; i++) {
|
||||
@ -87,39 +126,18 @@
|
||||
}
|
||||
|
||||
- (void)testAllScoresTennisGame1 {
|
||||
for (NSArray * score in [TennisTests allScores]) {
|
||||
|
||||
player1Score = [score[0] intValue];
|
||||
player2Score = [score[1] intValue];
|
||||
expectedScore = score[2];
|
||||
|
||||
TennisGame1 * game = [[TennisGame1 alloc] initWithPlayer1:@"player1" player2:@"player2"];
|
||||
[self checkAllScoresForGame:game];
|
||||
}
|
||||
TennisGame1 * game = [[TennisGame1 alloc] initWithPlayer1:@"player1" player2:@"player2"];
|
||||
[self checkAllScoresForGame:game];
|
||||
}
|
||||
|
||||
- (void)testAllScoresTennisGame2 {
|
||||
for (NSArray * score in [TennisTests allScores]) {
|
||||
|
||||
player1Score = [score[0] intValue];
|
||||
player2Score = [score[1] intValue];
|
||||
expectedScore = score[2];
|
||||
|
||||
TennisGame2 * game = [[TennisGame2 alloc] initWithPlayer1:@"player1" player2:@"player2"];
|
||||
[self checkAllScoresForGame:game];
|
||||
}
|
||||
TennisGame2 * game = [[TennisGame2 alloc] initWithPlayer1:@"player1" player2:@"player2"];
|
||||
[self checkAllScoresForGame:game];
|
||||
}
|
||||
|
||||
- (void)testAllScoresTennisGame3 {
|
||||
for (NSArray * score in [TennisTests allScores]) {
|
||||
|
||||
player1Score = [score[0] intValue];
|
||||
player2Score = [score[1] intValue];
|
||||
expectedScore = score[2];
|
||||
|
||||
TennisGame3 * game = [[TennisGame3 alloc] initWithPlayer1:@"player1" player2:@"player2"];
|
||||
[self checkAllScoresForGame:game];
|
||||
}
|
||||
TennisGame3 * game = [[TennisGame3 alloc] initWithPlayer1:@"player1" player2:@"player2"];
|
||||
[self checkAllScoresForGame:game];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user