Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Do it #1

Merged
merged 3 commits into from over 2 years ago

1 participant

Greg Sochanik
Greg Sochanik
Owner

No description provided.

added some commits
Greg Sochanik 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
Greg Sochanik Merge branch 'trunk' of github.com:7digital/SevenDigital.Api.Wrapper …
…into trunk
113965f
Greg Sochanik Merge in pull request from Featurist 261fed9
Greg Sochanik gregsochanik merged commit 261fed9 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 3 unique commits by 1 author.

Mar 04, 2012
Greg Sochanik 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
Greg Sochanik Merge branch 'trunk' of github.com:7digital/SevenDigital.Api.Wrapper …
…into trunk
113965f
Greg Sochanik Merge in pull request from Featurist 261fed9
This page is out of date. Refresh to see the latest.
36 src/SevenDigital.Api.Dynamic.Integration.Tests/DynamicXmlParserTests.cs
@@ -8,16 +8,13 @@
8 8 using SevenDigital.Api.Wrapper.EndpointResolution.OAuth;
9 9 using SevenDigital.Api.Wrapper.Utility.Http;
10 10
11   -namespace SevenDigital.Api.Dynamic.Integration.Tests
12   -{
  11 +namespace SevenDigital.Api.Dynamic.Integration.Tests {
13 12 [TestFixture]
14   - public class DynamicXmlParserTests
15   - {
  13 + public class DynamicXmlParserTests {
16 14 private EndpointResolver _endpointResolver;
17 15
18 16 [SetUp]
19   - public void SetUp()
20   - {
  17 + public void SetUp() {
21 18 IOAuthCredentials oAuthCredentials = EssentialDependencyCheck<IOAuthCredentials>.Instance;
22 19 IApiUri apiUri = EssentialDependencyCheck<IApiUri>.Instance;
23 20 var httpGetResolver = new HttpGetResolver();
@@ -26,12 +23,11 @@ public void SetUp()
26 23 _endpointResolver = new EndpointResolver(httpGetResolver, urlSigner, oAuthCredentials, apiUri);
27 24 }
28 25
29   - [Test]
30   - public void Can_get_an_artist()
31   - {
  26 + [Test]
  27 + public void Can_get_an_artist() {
32 28 const string endpoint = "artist/details";
33 29
34   - var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string, string> { { "artistId", "1" } } };
  30 + var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" } } };
35 31
36 32 string xml = _endpointResolver.HitEndpoint(endPointInfo);
37 33
@@ -46,25 +42,23 @@ public void Can_get_an_artist()
46 42 Assert.That(url, Is.StringStarting("http://www.7digital.com/artists/keane/"));
47 43 }
48 44
49   - [Test]
50   - public void Can_get_an_artists_releases()
51   - {
  45 + [Test]
  46 + public void Can_get_an_artists_releases() {
52 47 const string endpoint = "artist/releases";
53 48
54   - var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string, string> { { "artistId", "1" } } };
  49 + var endPointInfo = new EndPointInfo { Uri = endpoint, Parameters = new Dictionary<string,string> { { "artistId", "1" } } };
55 50
56 51 string xml = _endpointResolver.HitEndpoint(endPointInfo);
57 52
58 53 dynamic dx = new DynamicXmlParser(XDocument.Parse(xml));
59 54
60   - var titles = new List<string>();
61   - foreach (var variable in dx.releases.release)
62   - {
63   - titles.Add(variable.title.value);
64   - }
  55 + string [] titles = Enumerable.ToArray(Enumerable.Select<dynamic, string>(dx.releases.release, (Func<dynamic, string>) (r => r.title.value)));
65 56
66   - Assert.That(titles.Contains("Perfect Symmetry"));
67   - Assert.That(titles.Contains("Night Train"));
  57 + foreach (var title in titles) {
  58 + Console.WriteLine(title);
  59 + }
  60 +
  61 + Assert.That(titles, Has.Member("Night Train").And.Member("Perfect Symmetry"));
68 62 }
69 63 }
70 64 }
17 src/SevenDigital.Api.Dynamic/DynamicXmlParser.cs
@@ -6,8 +6,8 @@
6 6
7 7 namespace SevenDigital.Api.Dynamic
8 8 {
9   - public class DynamicXmlParser : DynamicObject, IEnumerable
10   - {
  9 + public class DynamicXmlParser : DynamicObject, IEnumerable, IEnumerable<object>
  10 + {
11 11 private readonly List<XElement> _elements;
12 12
13 13 public DynamicXmlParser(XDocument doc)
@@ -57,11 +57,14 @@ public override bool TryGetIndex(GetIndexBinder binder, object[] indexes, out ob
57 57 var ndx = (int)indexes[0];
58 58 result = new DynamicXmlParser(_elements[ndx]);
59 59 return true;
60   - }
61   -
62   - public IEnumerator GetEnumerator()
63   - {
64   - return _elements.Select(element => new DynamicXmlParser(element)).GetEnumerator();
  60 + }
  61 +
  62 + IEnumerator<object> IEnumerable<object>.GetEnumerator() {
  63 + return _elements.Select(element => new DynamicXmlParser(element)).GetEnumerator();
  64 + }
  65 +
  66 + public IEnumerator GetEnumerator() {
  67 + return ((IEnumerable<object>) this).GetEnumerator();
65 68 }
66 69 }
67 70 }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.