Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Do it #1

Merged
merged 3 commits into from

1 participant

@gregsochanik
Owner

No description provided.

added some commits
@gregsochanik BREAKING CHANGE - IUrlResolver methods now take a string instead of a…
… Uri

Added uriencoding option to the Dictionary to QueryString extension method

CHanged EndpointResolver so that all querystring parameter values are uriencoded by default before being sent to the api - with corresponding test
2374369
@gregsochanik Merge branch 'trunk' of github.com:7digital/SevenDigital.Api.Wrapper …
…into trunk
113965f
@gregsochanik Merge in pull request from Featurist
261fed9
@gregsochanik gregsochanik merged commit 261fed9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 4, 2012
  1. BREAKING CHANGE - IUrlResolver methods now take a string instead of a…

    authored
    … Uri
    
    Added uriencoding option to the Dictionary to QueryString extension method
    
    CHanged EndpointResolver so that all querystring parameter values are uriencoded by default before being sent to the api - with corresponding test
This page is out of date. Refresh to see the latest.
View
36 src/SevenDigital.Api.Dynamic.Integration.Tests/DynamicXmlParserTests.cs
@@ -8,16 +8,13 @@
using SevenDigital.Api.Wrapper.EndpointResolution.OAuth;
using SevenDigital.Api.Wrapper.Utility.Http;
-namespace SevenDigital.Api.Dynamic.Integration.Tests
-{
+namespace SevenDigital.Api.Dynamic.Integration.Tests {
[TestFixture]
- public class DynamicXmlParserTests
- {
+ public class DynamicXmlParserTests {
private EndpointResolver _endpointResolver;
[SetUp]
- public void SetUp()
- {
+ public void SetUp() {
IOAuthCredentials oAuthCredentials = EssentialDependencyCheck<IOAuthCredentials>.Instance;
IApiUri apiUri = EssentialDependencyCheck<IApiUri>.Instance;
var httpGetResolver = new HttpGetResolver();
@@ -26,12 +23,11 @@ public void SetUp()
_endpointResolver = new EndpointResolver(httpGetResolver, urlSigner, oAuthCredentials, apiUri);
}
- [Test]
- public void Can_get_an_artist()
- {
+ [Test]
+ public void Can_get_an_artist() {
const string endpoint = "artist/details";
- var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string, string> { { "artistId", "1" } } };
+ var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" } } };
string xml = _endpointResolver.HitEndpoint(endPointInfo);
@@ -46,25 +42,23 @@ public void Can_get_an_artist()
Assert.That(url, Is.StringStarting("http://www.7digital.com/artists/keane/"));
}
- [Test]
- public void Can_get_an_artists_releases()
- {
+ [Test]
+ public void Can_get_an_artists_releases() {
const string endpoint = "artist/releases";
- var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string, string> { { "artistId", "1" } } };
+ var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" } } };
string xml = _endpointResolver.HitEndpoint(endPointInfo);
dynamic dx = new DynamicXmlParser(XDocument.Parse(xml));
- var titles = new List<string>();
- foreach (var variable in dx.releases.release)
- {
- titles.Add(variable.title.value);
- }
+ string [] titles = Enumerable.ToArray(Enumerable.Select<dynamic, string>(dx.releases.release, (Func<dynamic, string>) (r => r.title.value)));
- Assert.That(titles.Contains("Perfect Symmetry"));
- Assert.That(titles.Contains("Night Train"));
+ foreach (var title in titles) {
+ Console.WriteLine(title);
+ }
+
+ Assert.That(titles, Has.Member("Night Train").And.Member("Perfect Symmetry"));
}
}
}
View
17 src/SevenDigital.Api.Dynamic/DynamicXmlParser.cs
@@ -6,8 +6,8 @@
namespace SevenDigital.Api.Dynamic
{
- public class DynamicXmlParser : DynamicObject, IEnumerable
- {
+ public class DynamicXmlParser : DynamicObject, IEnumerable, IEnumerable<object>
+ {
private readonly List<XElement> _elements;
public DynamicXmlParser(XDocument doc)
@@ -57,11 +57,14 @@ public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out ob
var ndx = (int)indexes[0];
result = new DynamicXmlParser(_elements[ndx]);
return true;
- }
-
- public IEnumerator GetEnumerator()
- {
- return _elements.Select(element => new DynamicXmlParser(element)).GetEnumerator();
+ }
+
+ IEnumerator<object> IEnumerable<object>.GetEnumerator() {
+ return _elements.Select(element => new DynamicXmlParser(element)).GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator() {
+ return ((IEnumerable<object>) this).GetEnumerator();
}
}
}
Something went wrong with that request. Please try again.