Permalink
Browse files

moving from wrong repo to caelum

  • Loading branch information...
0 parents commit 1aa66a4d553d567702705b30e51a1cb6eb872aa8 @guilhermesilveira guilhermesilveira committed Dec 26, 2009
Showing with 989 additions and 0 deletions.
  1. +10 −0 Local.testsettings
  2. +29 −0 README
  3. +116 −0 RestfuliClientTests/DynamicXmlResourceTest.cs
  4. +35 −0 RestfuliClientTests/Properties/AssemblyInfo.cs
  5. +88 −0 RestfuliClientTests/ResourceServiceTest.cs
  6. +80 −0 RestfuliClientTests/RestfulieClientTests.csproj
  7. +101 −0 RestfuliClientTests/RestfulieHttpVerbDiscoveryTest.cs
  8. BIN RestfuliClientTests/bin/Debug/RestfuliClientTests.dll
  9. BIN RestfuliClientTests/bin/Debug/RestfuliClientTests.pdb
  10. BIN RestfuliClientTests/bin/Debug/RestfulieClient.dll
  11. BIN RestfuliClientTests/bin/Debug/RestfulieClient.pdb
  12. BIN RestfuliClientTests/bin/Debug/Rhino.Mocks.dll
  13. +29 −0 RestfuliClientTests/helpers/LoadDocument.cs
  14. +24 −0 RestfuliClientTests/helpers/RemoteResourceFactory.cs
  15. BIN RestfuliClientTests/obj/Debug/ResolveAssemblyReference.cache
  16. +7 −0 RestfuliClientTests/obj/Debug/RestfuliClientTests.csproj.FileListAbsolute.txt
  17. BIN RestfuliClientTests/obj/Debug/RestfuliClientTests.dll
  18. BIN RestfuliClientTests/obj/Debug/RestfuliClientTests.pdb
  19. +24 −0 RestfuliClientTests/obj/Debug/RestfulieClientTests.csproj.FileListAbsolute.txt
  20. +10 −0 RestfuliClientTests/xmls/order.xml
  21. +11 −0 RestfuliClientTests/xmls/orderWithoutAtomLinks.xml
  22. +64 −0 RestfulieClient.sln
  23. BIN RestfulieClient.suo
  24. +6 −0 RestfulieClient.vsmdi
  25. +36 −0 RestfulieClient/Properties/AssemblyInfo.cs
  26. +58 −0 RestfulieClient/RestfulieClient.csproj
  27. BIN RestfulieClient/bin/Debug/RestfulieClient.dll
  28. BIN RestfulieClient/bin/Debug/RestfulieClient.pdb
  29. +15 −0 RestfulieClient/obj/Debug/RestfulieClient.csproj.FileListAbsolute.txt
  30. BIN RestfulieClient/obj/Debug/RestfulieClient.dll
  31. BIN RestfulieClient/obj/Debug/RestfulieClient.pdb
  32. +94 −0 RestfulieClient/resources/DynamicXmlResource.cs
  33. +20 −0 RestfulieClient/resources/ResourceService.cs
  34. +43 −0 RestfulieClient/service/HttpRemoteResourceService.cs
  35. +13 −0 RestfulieClient/service/IRemoteResourceService.cs
  36. +50 −0 RestfulieClient/service/RestfulieHttpVerbDiscovery.cs
  37. +26 −0 TraceAndTestImpact.testsettings
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<TestSettings name="Local" id="456d97a2-9272-4fad-aa33-68743b47866c" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
+ <Description>These are default test settings for a local test run.</Description>
+ <Deployment enabled="false" />
+ <Execution>
+ <TestTypeSpecific />
+ <AgentRule name="Execution Agents">
+ </AgentRule>
+ </Execution>
+</TestSettings>
29 README
@@ -0,0 +1,29 @@
+Typical hypermedia aware resource representation
+
+Trying to follow the definition of a RESTful application supporting resources with hypermedia content, a resource would be:
+
+<order>
+ <product>RESTful training</product>
+ <date>23/12/2009</date>
+ <atom:link rel="refresh" href="http://www.caelum.com.br/orders/1" xmlns:atom="http://www.w3.org/2005/Atom"/>
+ <atom:link rel="update" href="http://www.caelum.com.br/orders/1" xmlns:atom="http://www.w3.org/2005/Atom"/>
+ <atom:link rel="pay" href="http://www.caelum.com.br/orders/1/pay" xmlns:atom="http://www.w3.org/2005/Atom"/>
+ <atom:link rel="destroy" href="http://www.caelum.com.br/orders/1" xmlns:atom="http://www.w3.org/2005/Atom"/>
+</order>
+
+Restfulie C#: client-side
+
+Example on accessing a resource and its services through the restfulie C# API:
+
+Resource resource = new Resource()
+dynamic order = resource.FromXml("http://www.caelum.com.br/orders/3.xml");
+
+Console.WriteLine(order.product) ;
+
+Executing a state transition:
+ order.Pay();
+ order.Cancel();
+
+ Following some limitations:
+ - it does not update resource on server
+ - it does not supports the method names with the characteres (-,?,!), very common in ruby codes.
@@ -0,0 +1,116 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using RestfulieClientTests.helpers;
+using System.Xml.Linq;
+using Rhino.Mocks;
+using RestfulieClient.resources;
+using RestfuliClientTests.helpers;
+
+namespace RestfuliClientTests
+{
+ /// <summary>
+ /// Summary description for DynamicXmlResourceTest
+ /// </summary>
+ [TestClass]
+ public class DynamicXmlResourceTest
+ {
+ public DynamicXmlResourceTest()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ private TestContext testContextInstance;
+
+ /// <summary>
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///</summary>
+ public TestContext TestContext
+ {
+ get
+ {
+ return testContextInstance;
+ }
+ set
+ {
+ testContextInstance = value;
+ }
+ }
+
+ #region Additional test attributes
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // Use TestCleanup to run code after each test has run
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+ #endregion
+ [TestMethod]
+ public void ShouldBePossibleToLoadAXmlByTheyDynamicObject()
+ {
+ string xml = new LoadDocument().GetDocumentContent("order.xml");
+ XElement element = XElement.Parse(xml);
+
+ dynamic order = new DynamicXmlResource(element);
+ Assert.IsNotNull(order.date, "the attribute date is no expected");
+ Assert.IsNotNull(order.total, "the attribute total is no expected");
+ }
+
+ [TestMethod ]
+ public void ShouldBePossibleToExecuteDynamicMethodsInResource()
+ {
+ dynamic order = this.GetDynamicResourceWithServiceFake();
+ Assert.IsNotNull(order.Pay());
+ }
+
+
+ [Ignore]
+ public void ShouldBeAbleToAnswerToMethodRelName()
+ {
+ dynamic order = this.GetDynamicResourceWithServiceFake();
+ Assert.IsNotNull(order.Update());
+
+ }
+
+ [TestMethod]
+ public void LearningToReadAAtomLinkInXml()
+ {
+ dynamic order = this.GetDynamicResourceWithServiceFake();
+ Assert.IsNotNull(order.Pay());
+ }
+
+
+ private DynamicXmlResource GetDynamicResourceWithServiceFake()
+ {
+ XElement element;
+ IRemoteResourceService remoteService;
+ string xml = new LoadDocument().GetDocumentContent("order.xml");
+ element = XElement.Parse(xml);
+ remoteService = this.GetRemoteServiceFake();
+ return new DynamicXmlResource(element) { remoteResourceService = remoteService };
+ }
+
+ private IRemoteResourceService GetRemoteServiceFake()
+ {
+ return RemoteResourceFactory.GetRemoteResource();
+ }
+ }
+}
@@ -0,0 +1,35 @@
+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("RestfuliClientTests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("Prolins")]
+[assembly: AssemblyProduct("RestfuliClientTests")]
+[assembly: AssemblyCopyright("Copyright © Prolins 2009")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM componenets. 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("5b69e991-0542-4618-ade0-ca1e1084935a")]
+
+// 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 Revision and Build Numbers
+// by using the '*' as shown below:
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,88 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using RestfulieClientTests.helpers;
+using RestfulieClient.resources;
+using RestfuliClientTests.helpers;
+
+namespace RestfuliClientTests
+{
+ /// <summary>
+ /// Summary description for ResourceServiceTest
+ /// </summary>
+ [TestClass]
+ public class ResourceServiceTest
+ {
+ public ResourceServiceTest()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ private TestContext testContextInstance;
+
+ /// <summary>
+ ///Gets or sets the test context which provides
+ ///information about and functionality for the current test run.
+ ///</summary>
+ public TestContext TestContext
+ {
+ get
+ {
+ return testContextInstance;
+ }
+ set
+ {
+ testContextInstance = value;
+ }
+ }
+
+ #region Additional test attributes
+ //
+ // You can use the following additional attributes as you write your tests:
+ //
+ // Use ClassInitialize to run code before running the first test in the class
+ // [ClassInitialize()]
+ // public static void MyClassInitialize(TestContext testContext) { }
+ //
+ // Use ClassCleanup to run code after all tests in a class have run
+ // [ClassCleanup()]
+ // public static void MyClassCleanup() { }
+ //
+ // Use TestInitialize to run code before running each test
+ // [TestInitialize()]
+ // public void MyTestInitialize() { }
+ //
+ // Use TestCleanup to run code after each test has run
+ // [TestCleanup()]
+ // public void MyTestCleanup() { }
+ //
+ #endregion
+
+ [TestMethod]
+ public void ShoudBePossibleToLoadAResourceFromXml()
+ {
+
+ ResourceService resource = new ResourceService() { RemoteResourceService = RemoteResourceFactory.GetRemoteResource() };
+ dynamic order = resource.FromXml("http:\\localhost:3000\\order\\1.xml");
+
+ // verificando os atributos do recurso
+ Assert.IsNotNull(order.date);
+ Assert.IsNotNull(order.total);
+ }
+
+ [Ignore]
+ public void ShouldBePossibleToExecuteATransitionOfStateOfAResource()
+ {
+ ResourceService resource = new ResourceService() { RemoteResourceService = RemoteResourceFactory.GetRemoteResource() };
+ dynamic order = resource.FromXml("http:\\localhost:3000\\order\\1.xml");
+ Assert.IsNotNull(order.Pay());
+
+ }
+
+
+ }
+}
@@ -0,0 +1,80 @@
+<?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>
+ </ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{AD6766CF-FA52-4AB5-B3A4-81BD55BC92B1}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>RestfuliClientTests</RootNamespace>
+ <AssemblyName>RestfuliClientTests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ </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="Microsoft.CSharp" />
+ <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
+ <Reference Include="Rhino.Mocks">
+ <HintPath>..\..\libs\Rhino.Mocks-3.6\Rhino.Mocks.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.XML" />
+ <Reference Include="System.Xml.Linq" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="DynamicXmlResourceTest.cs" />
+ <Compile Include="helpers\LoadDocument.cs" />
+ <Compile Include="helpers\RemoteResourceFactory.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ResourceServiceTest.cs" />
+ <Compile Include="RestfulieHttpVerbDiscoveryTest.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="xmls\order.xml">
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\RestfulieClient\RestfulieClient.csproj">
+ <Project>{9C873FC6-81A7-432C-8541-7B18AE014209}</Project>
+ <Name>RestfulieClient</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <EmbeddedResource Include="xmls\orderWithoutAtomLinks.xml">
+ <SubType>Designer</SubType>
+ </EmbeddedResource>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\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>
Oops, something went wrong.

0 comments on commit 1aa66a4

Please sign in to comment.