mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
Reorganising test resources and GetTrackShoutsCommandTests
This commit is contained in:
parent
70a557097b
commit
1e6aa46f49
@ -1,12 +1,9 @@
|
|||||||
using System;
|
using IF.Lastfm.Core.Api;
|
||||||
using System.Collections.Generic;
|
using Moq;
|
||||||
using System.Linq;
|
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using IF.Lastfm.Core.Api;
|
|
||||||
using Moq;
|
|
||||||
|
|
||||||
namespace IF.Lastfm.Core.Tests.Api.Commands
|
namespace IF.Lastfm.Core.Tests.Api.Commands
|
||||||
{
|
{
|
||||||
@ -21,6 +18,9 @@ protected CommandTestsBase()
|
|||||||
|
|
||||||
public abstract void Constructor();
|
public abstract void Constructor();
|
||||||
public abstract Task HandleSuccessResponse();
|
public abstract Task HandleSuccessResponse();
|
||||||
|
public abstract Task HandleResponseSingle();
|
||||||
|
public abstract Task HandleEmptyResponse();
|
||||||
|
public abstract Task HandleErrorResponse();
|
||||||
|
|
||||||
protected HttpResponseMessage CreateResponseMessage(string message)
|
protected HttpResponseMessage CreateResponseMessage(string message)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
using System.Linq;
|
using IF.Lastfm.Core.Api.Commands.TrackApi;
|
||||||
|
using IF.Lastfm.Core.Tests.Resources;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using IF.Lastfm.Core.Api.Commands.TrackApi;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
|
|
||||||
namespace IF.Lastfm.Core.Tests.Api.Commands.TrackApi
|
namespace IF.Lastfm.Core.Tests.Api.Commands.TrackApi
|
||||||
{
|
{
|
||||||
@ -32,26 +33,50 @@ public override void Constructor()
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async override Task HandleSuccessResponse()
|
public async override Task HandleSuccessResponse()
|
||||||
{
|
{
|
||||||
var response = CreateResponseMessage(Encoding.UTF8.GetString(TestData.TrackGetShouts));
|
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShouts));
|
||||||
|
|
||||||
var parsed = await _command.HandleResponse(response);
|
var parsed = await _command.HandleResponse(response);
|
||||||
|
|
||||||
|
Assert.IsTrue(parsed.Success);
|
||||||
|
Assert.IsNotNull(parsed.Content);
|
||||||
Assert.IsTrue(parsed.Page == 5);
|
Assert.IsTrue(parsed.Page == 5);
|
||||||
Assert.IsTrue(parsed.Content.Count() == 7);
|
Assert.IsTrue(parsed.Content.Count() == 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The shouts API uses a different schema when there's only one shout in the page
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public async Task HandleResponseSingle()
|
public async override Task HandleResponseSingle()
|
||||||
{
|
{
|
||||||
var response = CreateResponseMessage(Encoding.UTF8.GetString(TestData.TrackGetShoutsSingle));
|
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShoutsSingle));
|
||||||
|
|
||||||
var parsed = await _command.HandleResponse(response);
|
var parsed = await _command.HandleResponse(response);
|
||||||
|
|
||||||
|
Assert.IsTrue(parsed.Success);
|
||||||
|
Assert.IsNotNull(parsed.Content);
|
||||||
Assert.IsTrue(parsed.Content.Count() == 1);
|
Assert.IsTrue(parsed.Content.Count() == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async override Task HandleEmptyResponse()
|
||||||
|
{
|
||||||
|
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShoutsEmpty));
|
||||||
|
|
||||||
|
var parsed = await _command.HandleResponse(response);
|
||||||
|
|
||||||
|
Assert.IsTrue(parsed.Success);
|
||||||
|
Assert.IsNotNull(parsed.Content);
|
||||||
|
Assert.IsTrue(!parsed.Content.Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public async override Task HandleErrorResponse()
|
||||||
|
{
|
||||||
|
var response = CreateResponseMessage(Encoding.UTF8.GetString(TrackApiResponses.TrackGetShoutsError));
|
||||||
|
|
||||||
|
var parsed = await _command.HandleResponse(response);
|
||||||
|
|
||||||
|
Assert.IsFalse(parsed.Success);
|
||||||
|
Assert.IsNotNull(parsed.Content);
|
||||||
|
Assert.IsTrue(!parsed.Content.Any());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,15 @@
|
|||||||
<Compile Include="LastFmTests.cs" />
|
<Compile Include="LastFmTests.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ResourceManager.cs" />
|
<Compile Include="ResourceManager.cs" />
|
||||||
<Compile Include="TestData.Designer.cs">
|
<Compile Include="Resources\AlbumApiResponses.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>TestData.resx</DependentUpon>
|
<DependentUpon>AlbumApiResponses.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Resources\TrackApiResponses.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>TrackApiResponses.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -87,17 +92,22 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</None>
|
</None>
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<None Include="Resources\AlbumGetInfo.json" />
|
<None Include="Resources\AlbumApi\AlbumGetInfo.json" />
|
||||||
<None Include="Resources\TrackGetShoutsSingle.json" />
|
<None Include="Resources\TrackApi\TrackGetShouts.json" />
|
||||||
|
<None Include="Resources\TrackApi\TrackGetShoutsEmpty.json" />
|
||||||
|
<None Include="Resources\TrackApi\TrackGetShoutsError.json" />
|
||||||
|
<None Include="Resources\TrackApi\TrackGetShoutsSingle.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="TestData.resx">
|
<EmbeddedResource Include="Resources\AlbumApiResponses.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
<LastGenOutput>TestData.Designer.cs</LastGenOutput>
|
<SubType>Designer</SubType>
|
||||||
|
<LastGenOutput>AlbumApiResponses.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Resources\TrackApiResponses.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>TrackApiResponses.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Resources\TrackGetShouts.json" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\IF.Lastfm.Core\IF.Lastfm.Core.csproj">
|
<ProjectReference Include="..\IF.Lastfm.Core\IF.Lastfm.Core.csproj">
|
||||||
@ -105,6 +115,9 @@
|
|||||||
<Name>IF.Lastfm.Core</Name>
|
<Name>IF.Lastfm.Core</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Api\Commands\AlbumApi\" />
|
||||||
|
</ItemGroup>
|
||||||
<Choose>
|
<Choose>
|
||||||
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
using System;
|
using IF.Lastfm.Core.Objects;
|
||||||
|
using IF.Lastfm.Core.Tests.Resources;
|
||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using IF.Lastfm.Core.Api;
|
|
||||||
using IF.Lastfm.Core.Objects;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Moq;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace IF.Lastfm.Core.Tests.Objects
|
namespace IF.Lastfm.Core.Tests.Objects
|
||||||
{
|
{
|
||||||
@ -15,7 +12,7 @@ public class AlbumTests
|
|||||||
{
|
{
|
||||||
public void AlbumParsesValidJson()
|
public void AlbumParsesValidJson()
|
||||||
{
|
{
|
||||||
var jo = ResourceManager.LoadResource(Encoding.UTF8.GetString(TestData.AlbumGetInfo));
|
var jo = ResourceManager.LoadResource(Encoding.UTF8.GetString(AlbumApiResponses.AlbumGetInfo));
|
||||||
|
|
||||||
var parsed = LastAlbum.ParseJToken(jo.SelectToken("album"));
|
var parsed = LastAlbum.ParseJToken(jo.SelectToken("album"));
|
||||||
|
|
||||||
|
73
src/IF.Lastfm.Core.Tests/Resources/AlbumApiResponses.Designer.cs
generated
Normal file
73
src/IF.Lastfm.Core.Tests/Resources/AlbumApiResponses.Designer.cs
generated
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// This code was generated by a tool.
|
||||||
|
// Runtime Version:4.0.30319.34014
|
||||||
|
//
|
||||||
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
|
// the code is regenerated.
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace IF.Lastfm.Core.Tests.Resources {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||||
|
/// </summary>
|
||||||
|
// This class was auto-generated by the StronglyTypedResourceBuilder
|
||||||
|
// class via a tool like ResGen or Visual Studio.
|
||||||
|
// To add or remove a member, edit your .ResX file then rerun ResGen
|
||||||
|
// with the /str option, or rebuild your VS project.
|
||||||
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
|
internal class AlbumApiResponses {
|
||||||
|
|
||||||
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
|
internal AlbumApiResponses() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the cached ResourceManager instance used by this class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
|
get {
|
||||||
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IF.Lastfm.Core.Tests.Resources.AlbumApiResponses", typeof(AlbumApiResponses).Assembly);
|
||||||
|
resourceMan = temp;
|
||||||
|
}
|
||||||
|
return resourceMan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Overrides the current thread's CurrentUICulture property for all
|
||||||
|
/// resource lookups using this strongly typed resource class.
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Byte[].
|
||||||
|
/// </summary>
|
||||||
|
internal static byte[] AlbumGetInfo {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("AlbumGetInfo", resourceCulture);
|
||||||
|
return ((byte[])(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -119,12 +119,6 @@
|
|||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
<data name="AlbumGetInfo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="AlbumGetInfo" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>resources\albumgetinfo.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>AlbumApi\AlbumGetInfo.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</data>
|
|
||||||
<data name="TrackGetShouts" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>resources\trackgetshouts.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
|
||||||
<data name="TrackGetShoutsSingle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
|
||||||
<value>resources\trackgetshoutssingle.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"shouts": {
|
||||||
|
"#text": "\n",
|
||||||
|
"artist": "Cristobal Tapia de Veer",
|
||||||
|
"track": "The Experiment",
|
||||||
|
"page": "0",
|
||||||
|
"perPage": "50",
|
||||||
|
"totalPages": "0",
|
||||||
|
"total": "0"
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"error": 6,
|
||||||
|
"message": "Artist not found",
|
||||||
|
"links": []
|
||||||
|
}
|
@ -1,14 +1,14 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.32559
|
// Runtime Version:4.0.30319.34014
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace IF.Lastfm.Core.Tests {
|
namespace IF.Lastfm.Core.Tests.Resources {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
||||||
@ -22,14 +22,14 @@ namespace IF.Lastfm.Core.Tests {
|
|||||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||||
internal class TestData {
|
internal class TrackApiResponses {
|
||||||
|
|
||||||
private static global::System.Resources.ResourceManager resourceMan;
|
private static global::System.Resources.ResourceManager resourceMan;
|
||||||
|
|
||||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||||
|
|
||||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||||
internal TestData() {
|
internal TrackApiResponses() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -39,7 +39,7 @@ internal TestData() {
|
|||||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||||
get {
|
get {
|
||||||
if (object.ReferenceEquals(resourceMan, null)) {
|
if (object.ReferenceEquals(resourceMan, null)) {
|
||||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IF.Lastfm.Core.Tests.TestData", typeof(TestData).Assembly);
|
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("IF.Lastfm.Core.Tests.Resources.TrackApiResponses", typeof(TrackApiResponses).Assembly);
|
||||||
resourceMan = temp;
|
resourceMan = temp;
|
||||||
}
|
}
|
||||||
return resourceMan;
|
return resourceMan;
|
||||||
@ -63,9 +63,9 @@ internal TestData() {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Byte[].
|
/// Looks up a localized resource of type System.Byte[].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static byte[] AlbumGetInfo {
|
internal static byte[] TrackGetShouts {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("AlbumGetInfo", resourceCulture);
|
object obj = ResourceManager.GetObject("TrackGetShouts", resourceCulture);
|
||||||
return ((byte[])(obj));
|
return ((byte[])(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,9 +73,19 @@ internal static byte[] AlbumGetInfo {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Byte[].
|
/// Looks up a localized resource of type System.Byte[].
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static byte[] TrackGetShouts {
|
internal static byte[] TrackGetShoutsEmpty {
|
||||||
get {
|
get {
|
||||||
object obj = ResourceManager.GetObject("TrackGetShouts", resourceCulture);
|
object obj = ResourceManager.GetObject("TrackGetShoutsEmpty", resourceCulture);
|
||||||
|
return ((byte[])(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Byte[].
|
||||||
|
/// </summary>
|
||||||
|
internal static byte[] TrackGetShoutsError {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("TrackGetShoutsError", resourceCulture);
|
||||||
return ((byte[])(obj));
|
return ((byte[])(obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
133
src/IF.Lastfm.Core.Tests/Resources/TrackApiResponses.resx
Normal file
133
src/IF.Lastfm.Core.Tests/Resources/TrackApiResponses.resx
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="TrackGetShouts" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>TrackApi\TrackGetShouts.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name="TrackGetShoutsEmpty" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>TrackApi\TrackGetShoutsEmpty.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name="TrackGetShoutsError" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>TrackApi\TrackGetShoutsError.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
<data name="TrackGetShoutsSingle" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>TrackApi\TrackGetShoutsSingle.json;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
@ -17,11 +17,12 @@ public PageResponse()
|
|||||||
{
|
{
|
||||||
Page = 1;
|
Page = 1;
|
||||||
TotalPages = 1;
|
TotalPages = 1;
|
||||||
|
Content = new List<T>();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
|
|
||||||
public IEnumerable<T> Content { get; internal set; }
|
public List<T> Content { get; internal set; }
|
||||||
|
|
||||||
public int Page { get; internal set; }
|
public int Page { get; internal set; }
|
||||||
|
|
||||||
@ -87,31 +88,31 @@ public static PageResponse<T> CreateSuccessResponse(IEnumerable<T> content)
|
|||||||
{
|
{
|
||||||
var r = new PageResponse<T>
|
var r = new PageResponse<T>
|
||||||
{
|
{
|
||||||
Content = content,
|
|
||||||
Success = true,
|
Success = true,
|
||||||
Error = LastFmApiError.None
|
Error = LastFmApiError.None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
r.Content.AddRange(content);
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PageResponse<T> CreateSuccessResponse(JToken itemsToken, JToken pageInfoToken, Func<JToken, T> parseToken, bool isOpenQueryToken = false)
|
public static PageResponse<T> CreateSuccessResponse(JToken itemsToken, JToken pageInfoToken, Func<JToken, T> parseToken, bool isOpenQueryToken = false)
|
||||||
{
|
{
|
||||||
var pageresponse = CreateSuccessResponse();
|
var pageresponse = CreateSuccessResponse();
|
||||||
var content = new List<T>();
|
|
||||||
|
|
||||||
if (itemsToken.Children().Any())
|
if (itemsToken != null && itemsToken.Children().Any())
|
||||||
{
|
{
|
||||||
// array notation isn't used on the api when only one object is available
|
// array notation isn't used on the api when only one object is available
|
||||||
if (itemsToken.Type != JTokenType.Array)
|
if (itemsToken.Type != JTokenType.Array)
|
||||||
{
|
{
|
||||||
var item = parseToken(itemsToken);
|
var item = parseToken(itemsToken);
|
||||||
content.Add(item);
|
pageresponse.Content.Add(item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var items = itemsToken.Children().Select(parseToken);
|
var items = itemsToken.Children().Select(parseToken);
|
||||||
content.AddRange(items);
|
pageresponse.Content.AddRange(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,11 +129,9 @@ public static PageResponse<T> CreateSuccessResponse(JToken itemsToken, JToken pa
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pageresponse.AddDefaultPageInfo(content.Count);
|
pageresponse.AddDefaultPageInfo(pageresponse.Content.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
pageresponse.Content = content;
|
|
||||||
|
|
||||||
return pageresponse;
|
return pageresponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user