Permalink
Browse files

Import project into Git

  • Loading branch information...
0 parents commit 8e40bb8a0703cad05cba0b94357b2d7c54fd611e @igstan committed Oct 24, 2010
Showing with 2,560 additions and 0 deletions.
  1. +1 −0 .gitattributes
  2. +11 −0 .gitignore
  3. +593 −0 Fixtures/reading-list.json
  4. +38 −0 GoogleReader.API.Tests/ExpectOn.cs
  5. +63 −0 GoogleReader.API.Tests/GoogleReader.API.Tests.csproj
  6. +9 −0 GoogleReader.API.Tests/GoogleReader.API.Tests.nunit
  7. +116 −0 GoogleReader.API.Tests/GoogleReaderTest.cs
  8. +36 −0 GoogleReader.API.Tests/Properties/AssemblyInfo.cs
  9. +63 −0 GoogleReader.API/AuthorizedHttpClient.cs
  10. +106 −0 GoogleReader.API/GoogleReader.API.csproj
  11. +13 −0 GoogleReader.API/HttpClient.cs
  12. +62 −0 GoogleReader.API/JsonDataContract.cs
  13. +36 −0 GoogleReader.API/Properties/AssemblyInfo.cs
  14. +104 −0 GoogleReader.API/ReaderAccount.cs
  15. +13 −0 GoogleReader.API/ReaderUrls.cs
  16. +84 −0 GoogleReader.API/SimpleHttpClient.cs
  17. +28 −0 GoogleReader.API/Subscription.cs
  18. +16 −0 GoogleReader.API/SubscriptionItem.cs
  19. BIN Lib/NUnit/nunit.framework.dll
  20. BIN Lib/NUnit/nunit.mocks.dll
  21. +18 −0 Nemira.Tests/AllTests.cs
  22. +62 −0 Nemira.Tests/Nemira.Tests.csproj
  23. +36 −0 Nemira.Tests/Properties/AssemblyInfo.cs
  24. +54 −0 Nemira.sln
  25. +21 −0 Nemira/AddSubscription.xaml
  26. +27 −0 Nemira/AddSubscription.xaml.cs
  27. +14 −0 Nemira/App.xaml
  28. +31 −0 Nemira/App.xaml.cs
  29. +42 −0 Nemira/Buttons.xaml
  30. BIN Nemira/Images/add.png
  31. BIN Nemira/Images/feed.png
  32. BIN Nemira/Images/feed_add.png
  33. BIN Nemira/Images/feed_delete.png
  34. BIN Nemira/Images/feed_edit.png
  35. BIN Nemira/Images/feed_error.png
  36. BIN Nemira/Images/feed_go.png
  37. BIN Nemira/Images/igs.ico
  38. +46 −0 Nemira/LoginWindow.xaml
  39. +41 −0 Nemira/LoginWindow.xaml.cs
  40. +120 −0 Nemira/MainWindow.xaml
  41. +141 −0 Nemira/MainWindow.xaml.cs
  42. +206 −0 Nemira/Nemira.csproj
  43. +55 −0 Nemira/Properties/AssemblyInfo.cs
  44. +63 −0 Nemira/Properties/Resources.Designer.cs
  45. +120 −0 Nemira/Properties/Resources.resx
  46. +30 −0 Nemira/Properties/Settings.Designer.cs
  47. +7 −0 Nemira/Properties/Settings.settings
  48. +20 −0 Nemira/StubHttpClient.cs
  49. +14 −0 TODO
@@ -0,0 +1 @@
+*.xaml diff
@@ -0,0 +1,11 @@
+*.user
+*.suo
+*.sln.cache
+
+# NUnit stuff
+*.VisualState.xml
+TestResult.xml
+
+bin
+obj
+publish

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Mocks;
+
+namespace GoogleReader.API.Tests
+{
+ class ExpectOn<T>
+ {
+ private string expectedMethodCall;
+ private List<object> expectedArguments = new List<object>();
+ private DynamicMock mock;
+
+ public ExpectOn()
+ {
+ mock = new DynamicMock(typeof(T));
+ }
+
+ public ExpectOn<T> MethodCall(string methodName)
+ {
+ expectedMethodCall = methodName;
+ return this;
+ }
+
+ public ExpectOn<T> WithArgument(object arg)
+ {
+ expectedArguments.Add(arg);
+ return this;
+ }
+
+ public T ToReturn(object returnValue)
+ {
+ mock.ExpectAndReturn(expectedMethodCall, returnValue, expectedArguments.ToArray());
+ return (T) mock.MockInstance;
+ }
+ }
+}
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{0D76A877-680D-46F8-AF5D-4E128DB83D6F}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>GoogleReader.API.Tests</RootNamespace>
+ <AssemblyName>GoogleReader.API.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="nunit.framework, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="nunit.mocks, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL" />
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="ExpectOn.cs" />
+ <Compile Include="GoogleReaderTest.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\GoogleReader.API\GoogleReader.API.csproj">
+ <Project>{3572FB41-219C-47DB-8706-3533FF8494F6}</Project>
+ <Name>GoogleReader.API</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+ Other similar extension points exist, see Microsoft.Common.targets.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,9 @@
+<NUnitProject>
+ <Settings activeconfig="Debug" />
+ <Config name="Debug" binpathtype="Auto">
+ <assembly path="bin\Debug\GoogleReader.API.Tests.dll" />
+ </Config>
+ <Config name="Release" binpathtype="Auto">
+ <assembly path="bin\Release\GoogleReader.API.Tests.dll" />
+ </Config>
+</NUnitProject>
@@ -0,0 +1,116 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using NUnit.Framework;
+using GoogleReader.API;
+
+namespace GoogleReader.API.Tests
+{
+ [TestFixture]
+ public class GoogleReaderTest
+ {
+ private ReaderUrls endpointUrls = new ReaderUrls()
+ {
+ SubscriptionList = "subscriptions-url",
+ SubscriptionItems = "subscription-items-url",
+ };
+
+ [Test]
+ public void CanFetchSubscriptionList()
+ {
+ var httpClient = new StubHttpClient()
+ {
+ ExpectedUrl = endpointUrls.SubscriptionList,
+ ExpectedResponse = @"{
+ ""subscriptions"": [
+ {
+ ""id"": ""feed/http://feeds.feedburner.com/ajaxian"",
+ ""title"": ""Ajaxian » Front Page""
+ }
+ ]
+ }",
+ };
+
+ var reader = new ReaderAccount(httpClient, endpointUrls);
+
+ Assert.AreEqual("feed/http://feeds.feedburner.com/ajaxian", reader.Subscriptions.ElementAt(0).Id);
+ Assert.AreEqual("Ajaxian » Front Page", reader.Subscriptions.ElementAt(0).Title);
+ }
+
+ [Test]
+ public void CanParseAtomBasedSubscriptionItems()
+ {
+ var httpClient = new StubHttpClient()
+ {
+ ExpectedUrl = endpointUrls.SubscriptionItems + "feed%2Fid", // feed ID must be URL-encoded
+ ExpectedResponse = @"{
+ ""items"": [
+ {
+ ""title"": ""Ajaxian » Front Page"",
+ ""content"": {
+ ""content"": ""Dummy Content""
+ }
+ }
+ ]
+ }",
+ };
+
+ var reader = new ReaderAccount(httpClient, endpointUrls);
+ var subscription = new Subscription(null)
+ {
+ Id = "feed/id",
+ };
+
+ Assert.AreEqual("Ajaxian » Front Page", reader.ItemsForSubscription(subscription).ElementAt(0).Title);
+ Assert.AreEqual("Dummy Content", reader.ItemsForSubscription(subscription).ElementAt(0).Content);
+ }
+
+ [Test]
+ public void CanParseRssBasedSubscriptionItems()
+ {
+ var httpClient = new StubHttpClient()
+ {
+ ExpectedUrl = endpointUrls.SubscriptionItems + "feed%2Fid", // feed ID must be URL-encoded
+ ExpectedResponse = @"{
+ ""items"": [
+ {
+ ""title"": ""Ajaxian » Front Page"",
+ ""summary"": {
+ ""content"": ""Dummy Content""
+ }
+ }
+ ]
+ }",
+ };
+
+ var reader = new ReaderAccount(httpClient, endpointUrls);
+ var subscription = new Subscription(null)
+ {
+ Id = "feed/id",
+ };
+
+ Assert.AreEqual("Ajaxian » Front Page", reader.ItemsForSubscription(subscription).ElementAt(0).Title);
+ Assert.AreEqual("Dummy Content", reader.ItemsForSubscription(subscription).ElementAt(0).Content);
+ }
+
+ class StubHttpClient : HttpClient
+ {
+ public string ExpectedUrl { get; set; }
+
+ public string ExpectedResponse { get; set; }
+
+ public string GET(string url)
+ {
+ Assert.AreEqual(ExpectedUrl, url);
+ return ExpectedResponse;
+ }
+
+ public string GET(string url, IDictionary<string, string> args)
+ {
+ Assert.AreEqual(ExpectedUrl, url);
+ return ExpectedResponse;
+ }
+ }
+ }
+}
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("GoogleReader.API.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("GoogleReader.API.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2010")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("cd96637a-bee7-4550-a5c8-b1670d16212b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+
+namespace GoogleReader.API
+{
+ public class AuthorizedHttpClient : SimpleHttpClient
+ {
+ private const string LOGIN_URL = "https://www.google.com/accounts/ClientLogin";
+ private const string TOKEN_URL = "https://www.google.com/reader/api/0/token";
+
+ private string email;
+ private string password;
+ private string authToken;
+ private string readerToken;
+
+ public AuthorizedHttpClient(string email, string password)
+ {
+ this.email = email;
+ this.password = password;
+ }
+
+ public override string GET(string url, IDictionary<string, string> args, IDictionary<string, string> headers)
+ {
+ if (NotAuthorized()) Authorize();
+
+ headers.Add("Authorization", String.Format("GoogleLogin auth={0}", authToken));
+ return base.GET(url, args, headers);
+ }
+
+ private bool NotAuthorized()
+ {
+ return authToken == null && readerToken == null;
+ }
+
+ private void Authorize()
+ {
+ authToken = Authenticate(email, password);
+ readerToken = AuthorizeWithReader(authToken);
+ }
+
+ private string Authenticate(string email, string password)
+ {
+ var response = POST(LOGIN_URL, new Dictionary<string, string>()
+ {
+ {"Email", email},
+ {"Passwd", password},
+ {"source", "cli-script"},
+ {"service", "reader"},
+ });
+
+ return response.Split('\n')[2].Split('=')[1];
+ }
+
+ private string AuthorizeWithReader(string authToken)
+ {
+ return GET(TOKEN_URL);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 8e40bb8

Please sign in to comment.