Skip to content
This repository has been archived by the owner on Sep 1, 2022. It is now read-only.

Commit

Permalink
rtm.auth.getTokenの実装
Browse files Browse the repository at this point in the history
  • Loading branch information
masaru-b-cl committed Apr 24, 2012
1 parent dbc7c27 commit 61a4caa
Show file tree
Hide file tree
Showing 57 changed files with 5,977 additions and 156 deletions.
Binary file modified ReactiveTheMilk.Test/MolesAssemblies/ReactiveTheMilk.Moles.dll
Binary file not shown.
204 changes: 200 additions & 4 deletions ReactiveTheMilk.Test/MolesAssemblies/ReactiveTheMilk.Moles.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions ReactiveTheMilk.Test/ReactiveTheMilk.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ReactiveProperty.NET40, Version=0.3.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.0.3.1.0\lib\NET40\ReactiveProperty.NET40.dll</HintPath>
<Reference Include="ReactiveProperty.NET40, Version=0.3.2.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ReactiveProperty.0.3.2.0\lib\NET40\ReactiveProperty.NET40.dll</HintPath>
</Reference>
<Reference Include="ReactiveProperty.NET40.Moles, Version=0.3.1.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="ReactiveTheMilk.Moles, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
Expand All @@ -53,11 +54,11 @@
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Moles, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0ae41878053f6703, processorArchitecture=MSIL" />
<Reference Include="System.Reactive, Version=1.0.10621.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Rx-Main.1.0.10621\lib\Net4\System.Reactive.dll</HintPath>
<HintPath>..\packages\Rx-Main.1.0.11226\lib\Net4\System.Reactive.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\ReactiveProperty.0.3.1.0\lib\NET40\System.Windows.Interactivity.dll</HintPath>
<HintPath>..\packages\ReactiveProperty.0.3.2.0\lib\NET40\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
Expand Down
88 changes: 62 additions & 26 deletions ReactiveTheMilk.Test/RtmAuthorizerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,38 @@

namespace ReactiveTheMilk
{
[TestClass]
public class RtmAuthorizerTest
{
private const string ApiKey = "api_key";
private const string Secret = "signature";
private const string Frob = "frob";
[TestClass]
public class RtmAuthorizerTest
{
private const string ApiKey = "api_key";
private const string Secret = "signature";
private const string Frob = "frob";

private RtmAuthorizer rtm;

[TestInitialize]
public void SetUp()
{
rtm = new SRtmAuthorizer(ApiKey, Secret);
}
[TestInitialize]
public void SetUp()
{
rtm = new SRtmAuthorizer(ApiKey, Secret);
}

[TestMethod]
[HostType("Moles")]
public void TestGetFrob()
{
var rspRaw = @"<rsp stat=""ok""><frob>frob</frob></rsp>";
[TestMethod]
[HostType("Moles")]
public void TestGetFrob()
{
var rspRaw = @"<rsp stat=""ok""><frob>frob</frob></rsp>";

MRtmBase.AllInstances.GetRtmResponseString = (a, method) =>
{
method.Is("rtm.auth.getFrob");
return Observable.Return(rspRaw);
};
new MRtmBase(rtm).GetRtmResponseString = (method) =>
{
method.Is("rtm.auth.getFrob");
return Observable.Return(rspRaw);
};

IObservable<string> result = rtm.GetFrob();
string frob = result.First();
IObservable<string> result = rtm.GetFrob();
string frob = result.First();

frob.Is("frob");
}
frob.Is("frob");
}

[TestMethod]
[HostType("Moles")]
Expand Down Expand Up @@ -80,5 +80,41 @@ public void TestGetAuthenticationUrl()
url.Is("http://www.rememberthemilk.com/services/auth/?api_key=api_key&perms=delete&frob=frob&api_sig=signature");
}

}
[TestMethod]
[HostType("Moles")]
public void TestGetToken()
{
var rspRaw = @"
<rsp stat=""ok"">
<auth>
<token>410c57262293e9d937ee5be75eb7b0128fd61b61</token>
<perms>delete</perms>
<user id=""1"" username=""bob"" fullname=""Bob T. Monkey"" />
</auth>
</rsp>
";

new MRtmBase(rtm).GetRtmResponseStringParameterArray = (method, parameters) =>
{
method.Is("rtm.auth.getToken");
var param = parameters.First();
param.Key.Is("frob");
param.Value.Is("frobvalue");
return Observable.Return(rspRaw);
};

var frob = "frobvalue";
IObservable<RtmToken> result = rtm.GetToken(frob);
RtmToken token = result.First();

token.Token.Is("410c57262293e9d937ee5be75eb7b0128fd61b61");
token.Perms.Is("delete");
RtmUser user = token.User;
user.Id.Is(1);
user.Username.Is("bob");
user.Fullname.Is("Bob T. Monkey");
}

}
}
Loading

0 comments on commit 61a4caa

Please sign in to comment.