mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Add a broken unit test demonstrating the issue described in #481.
This commit is contained in:
@@ -544,6 +544,8 @@
|
||||
73D3907514CA1AE20093E3D6 /* parent.json in Resources */ = {isa = PBXBuildFile; fileRef = 73D3907114CA19F90093E3D6 /* parent.json */; };
|
||||
73D3907614CA1AE60093E3D6 /* child.json in Resources */ = {isa = PBXBuildFile; fileRef = 73D3907314CA1A4A0093E3D6 /* child.json */; };
|
||||
73D3907714CA1AE60093E3D6 /* child.json in Resources */ = {isa = PBXBuildFile; fileRef = 73D3907314CA1A4A0093E3D6 /* child.json */; };
|
||||
73D3907914CA1DD40093E3D6 /* channels.xml in Resources */ = {isa = PBXBuildFile; fileRef = 73D3907814CA1D710093E3D6 /* channels.xml */; };
|
||||
73D3907A14CA1DD50093E3D6 /* channels.xml in Resources */ = {isa = PBXBuildFile; fileRef = 73D3907814CA1D710093E3D6 /* channels.xml */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -912,6 +914,7 @@
|
||||
49D275AC14C9F3020090845D /* RKISO8601DateFormatter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RKISO8601DateFormatter.m; sourceTree = "<group>"; };
|
||||
73D3907114CA19F90093E3D6 /* parent.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = parent.json; sourceTree = "<group>"; };
|
||||
73D3907314CA1A4A0093E3D6 /* child.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = child.json; sourceTree = "<group>"; };
|
||||
73D3907814CA1D710093E3D6 /* channels.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = channels.xml; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -1426,6 +1429,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
25160FED1456F2330060A5C5 /* attributes_without_text_content.xml */,
|
||||
73D3907814CA1D710093E3D6 /* channels.xml */,
|
||||
25160FEE1456F2330060A5C5 /* container_attributes.xml */,
|
||||
25160FEF1456F2330060A5C5 /* national_weather_service.xml */,
|
||||
25160FF01456F2330060A5C5 /* orders.xml */,
|
||||
@@ -1975,6 +1979,7 @@
|
||||
25A341DA147C2F370009758D /* OCMock-Info.plist in Resources */,
|
||||
73D3907414CA1AE00093E3D6 /* parent.json in Resources */,
|
||||
73D3907614CA1AE60093E3D6 /* child.json in Resources */,
|
||||
73D3907914CA1DD40093E3D6 /* channels.xml in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2033,6 +2038,7 @@
|
||||
25A341DB147C2F370009758D /* OCMock-Info.plist in Resources */,
|
||||
73D3907514CA1AE20093E3D6 /* parent.json in Resources */,
|
||||
73D3907714CA1AE60093E3D6 /* child.json in Resources */,
|
||||
73D3907A14CA1DD50093E3D6 /* channels.xml in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
11
Specs/Fixtures/XML/channels.xml
Normal file
11
Specs/Fixtures/XML/channels.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<Channels>
|
||||
<Channel Identifier="1172" Title="MySpecialTitle" Position="2234">
|
||||
<Image>http://domain.com/Images/MySpecialTitle.png</Image>
|
||||
<Image Width="65" Height="35">http://domain.com/Images/65x35/2234.png</Image>
|
||||
<Stream Identifier="MySpecialTitle" Index="0">MySpecialTitle</Stream>
|
||||
<Languages>it</Languages>
|
||||
<Program Identifier="42883461" Start="2011-12-19 20:00:00Z" End="2011-12-19 21:00:00Z" Title="Program Title 1"/>
|
||||
<Program Identifier="42883471" Start="2011-12-19 21:00:00Z" End="2011-12-19 23:00:00Z" Title="Program Title"/>
|
||||
</Channel>
|
||||
</Channels>
|
||||
@@ -183,4 +183,39 @@
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testShouldParseXMLElementsAndAttributesProperly {
|
||||
NSString* XML = RKSpecReadFixture(@"channels.xml");
|
||||
RKXMLParserLibXML* parser = [[RKXMLParserLibXML new] autorelease];
|
||||
NSDictionary* result = [parser parseXML:XML];
|
||||
NSDictionary *channel = [[result objectForKey:@"Channels"] objectForKey:@"Channel"];
|
||||
assertThat(channel, is(notNilValue()));
|
||||
|
||||
// Check to see if the Channel attributes are properly parsed
|
||||
assertThat([channel objectForKey:@"Identifier"], is(equalTo(@"1172")));
|
||||
assertThat([channel objectForKey:@"Title"], is(equalTo(@"MySpecialTitle")));
|
||||
assertThat([channel objectForKey:@"Position"], is(equalTo(@"2234")));
|
||||
|
||||
// Check to see if the Channel elements are properly parsed
|
||||
assertThat([channel objectForKey:@"Languages"], is(equalTo(@"it")));
|
||||
|
||||
assertThat([channel objectForKey:@"Stream"], is(equalTo(@"MySpecialTitle")));
|
||||
assertThat([[channel objectForKey:@"Stream"] objectForKey:@"Identifier"], is(equalTo(@"MySpecialTitle")));
|
||||
assertThat([[channel objectForKey:@"Stream"] objectForKey:@"Index"], is(equalTo(@"0")));
|
||||
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:0] objectForKey:@"Identifier"], is(equalTo(@"42883461")));
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:0] objectForKey:@"Start"], is(equalTo(@"2011-12-19 20:00:00Z")));
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:0] objectForKey:@"End"], is(equalTo(@"2011-12-19 21:00:00Z")));
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:0] objectForKey:@"Title"], is(equalTo(@"Program Title 1")));
|
||||
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:1] objectForKey:@"Identifier"], is(equalTo(@"42883471")));
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:1] objectForKey:@"Start"], is(equalTo(@"2011-12-19 21:00:00Z")));
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:1] objectForKey:@"End"], is(equalTo(@"2011-12-19 23:00:00Z")));
|
||||
assertThat([[[channel objectForKey:@"Program"] objectAtIndex:1] objectForKey:@"Title"], is(equalTo(@"Program Title")));
|
||||
|
||||
assertThat([[channel objectForKey:@"Image"] objectAtIndex:0], is(equalTo(@"http://domain.com/Images/MySpecialTitle.png")));
|
||||
assertThat([[channel objectForKey:@"Image"] objectAtIndex:1], is(equalTo(@"http://domain.com/Images/65x35/2234.png")));
|
||||
assertThat([[[channel objectForKey:@"Image"] objectAtIndex:1] objectForKey:@"Width"], is(equalTo(@"65")));
|
||||
assertThat([[[channel objectForKey:@"Image"] objectAtIndex:1] objectForKey:@"Height"], is(equalTo(@"35")));
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user