Skip to content

Commit

Permalink
adding readme with release steps, and working through running tests l…
Browse files Browse the repository at this point in the history
…ocally instead of on device
  • Loading branch information
edatkinvey committed Jan 14, 2015
1 parent 44e663a commit 988336a
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 218 deletions.
4 changes: 2 additions & 2 deletions Android-Libtester/Android-Libtester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestClient.cs" />
<Compile Include="TestUser.cs" />
<Compile Include="TestAppData.cs" />
<Compile Include="ReflectionHelper.cs" />
<Compile Include="LinqBuilderTest.cs" />
<Compile Include="MyEntity.cs" />
<Compile Include="TestIntAppData.cs" />
<Compile Include="MyEntity.cs" />
<Compile Include="TestAppData.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
Expand Down
30 changes: 30 additions & 0 deletions LibTester/DefaultContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using LinqExtender;
using Ast = LinqExtender.Ast;

namespace LibTester
{
/// <summary>
/// Default context to be queried.
/// </summary>
/// <typeparam name="T">Target type</typeparam>
public class DefaultContext<T> : ExpressionVisitor, IQueryContext<T>
{
/// <summary>
/// Invoked during execution of the query , with the
/// pre populated expression tree.
/// </summary>
/// <param name="expression">Target expression block</param>
/// <returns>Expected result</returns>
public IEnumerable<T> Execute(Ast.Expression expression)
{
//TODO: Visit the extender expression to build your meta

this.Visit(expression);

///TOOD: return your result.
return null;
}
}
}
86 changes: 86 additions & 0 deletions LibTester/ExpressionVisitor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using System;
using LinqExtender;
using Ast = LinqExtender.Ast;


namespace LibTester
{
public class ExpressionVisitor
{
internal Ast.Expression Visit(Ast.Expression expression)
{
switch (expression.CodeType)
{
case CodeType.BlockExpression:
return VisitBlockExpression((Ast.BlockExpression)expression);
case CodeType.TypeExpression:
return VisitTypeExpression((Ast.TypeExpression)expression);
case CodeType.LambdaExpresion:
return VisitLambdaExpression((Ast.LambdaExpression)expression);
case CodeType.LogicalExpression:
return VisitLogicalExpression((Ast.LogicalExpression)expression);
case CodeType.BinaryExpression:
return VisitBinaryExpression((Ast.BinaryExpression)expression);
case CodeType.LiteralExpression:
return VisitLiteralExpression((Ast.LiteralExpression)expression);
case CodeType.MemberExpression:
return VisitMemberExpression((Ast.MemberExpression)expression);
case CodeType.OrderbyExpression:
return VisitOrderbyExpression((Ast.OrderbyExpression)expression);
}

throw new ArgumentException("Expression type is not supported");
}

public virtual Ast.Expression VisitTypeExpression(Ast.TypeExpression typeExpression)
{
return typeExpression;
}

public virtual Ast.Expression VisitBlockExpression(Ast.BlockExpression blockExpression)
{
foreach (var expression in blockExpression.Expressions)
this.Visit(expression);

return blockExpression;
}

public virtual Ast.Expression VisitLogicalExpression(Ast.LogicalExpression expression)
{
this.Visit(expression.Left);
this.Visit(expression.Right);
return expression;
}

public virtual Ast.Expression VisitLambdaExpression(Ast.LambdaExpression expression)
{
if (expression.Body != null)
return this.Visit(expression.Body);
return expression;
}

public virtual Ast.Expression VisitBinaryExpression(Ast.BinaryExpression expression)
{
this.Visit(expression.Left);
this.Visit(expression.Right);

return expression;
}

public virtual Ast.Expression VisitMemberExpression(Ast.MemberExpression expression)
{
return expression;
}

public virtual Ast.Expression VisitLiteralExpression(Ast.LiteralExpression expression)
{
return expression;
}

public virtual Ast.Expression VisitOrderbyExpression(Ast.OrderbyExpression expression)
{
return expression;
}

}
}
65 changes: 65 additions & 0 deletions LibTester/LibTester.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F305304B-081C-44B5-BE53-F24A07BCDC56}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>LibTester</RootNamespace>
<AssemblyName>LibTester</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="nunit.framework">
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="LinqExtender">
<HintPath>..\packages\LinqExtender.3.0.1\lib\LinqExtender.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Test.cs" />
<Compile Include="TestAppData.cs" />
<Compile Include="ExpressionVisitor.cs" />
<Compile Include="DefaultContext.cs" />
<Compile Include="MyEntity.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" />
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Kinvey-Xamarin\Kinvey-Xamarin.csproj">
<Project>{6644D98D-026B-48E9-95A3-61C4D98D82E7}</Project>
<Name>Kinvey-Xamarin</Name>
</ProjectReference>
<ProjectReference Include="..\Kinvey-Utils\Kinvey-Utils.csproj">
<Project>{444456B1-5B55-48D6-9637-00ADCA92B7C9}</Project>
<Name>Kinvey-Utils</Name>
</ProjectReference>
<ProjectReference Include="..\RestSharp.Portable\RestSharp.Portable.csproj">
<Project>{BA2352E1-CB07-4795-A2EB-F70720B2BBC9}</Project>
<Name>RestSharp.Portable</Name>
</ProjectReference>
</ItemGroup>
</Project>
32 changes: 32 additions & 0 deletions LibTester/MyEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using RestSharp;


namespace AndroidLibtester
{
public class MyEntity
{

public MyEntity(string id){
this.ID = id;
}

public MyEntity(){}

public string ID {get; set;}


public string Name{get;set;}


public string Email{get;set;}


public string lowercasetest{get;set;}


public bool IsAvailable{get; set;}

}
}

16 changes: 16 additions & 0 deletions LibTester/Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using NUnit.Framework;
using System;

namespace LibTester
{
[TestFixture ()]
public class Test
{
[Test ()]
public void TestCase ()
{
// Assert.True (false);
}
}
}

109 changes: 109 additions & 0 deletions LibTester/TestAppData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using NUnit.Framework;
using KinveyXamarin;
using System.Reflection;
using RestSharp;
using LinqExtender;

namespace AndroidLibtester
{
[TestFixture]
public class TestAppData
{

string appkey = "123";
string appsecret = "123";
Client testClient;
AppData<MyEntity> testData;
string myCollection = "myCollection";

[SetUp]
public void Setup ()
{
testClient = new Client.Builder (appkey, appsecret).build ();
testData = testClient.AppData<MyEntity> (myCollection, typeof(MyEntity));
}


[TearDown]
public void Tear ()
{
}


[Test()]
public void TestGetEntity()
{

string someID = "some id";
AppData<MyEntity>.GetEntityRequest req = testData.GetEntityBlocking (someID);

RestRequest restReq = req.BuildRestRequest ();
Assert.True (restReq.Method == Method.GET);
Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.UrlSegment;
}).Count >= 2);

Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.HttpHeader;
}).Count >= 3);

}

[Test()]
public void TestGetAll()
{
AppData<MyEntity>.GetRequest req = testData.GetBlocking ();

RestRequest restReq = req.BuildRestRequest ();
Assert.True (restReq.Method == Method.GET);
Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.UrlSegment;
}).Count >= 1);

Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.HttpHeader;
}).Count >= 3);

}

[Test()]
public void TestSaveEntity()
{

AppData<MyEntity>.SaveRequest req = testData.SaveBlocking (new MyEntity());

RestRequest restReq = req.BuildRestRequest ();
Assert.True (restReq.Method == Method.POST);
Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.UrlSegment;
}).Count >= 1);

Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.HttpHeader;
}).Count >= 3);

}

[Test()]
public void TestDeleteEntity()
{
string someID = "some id";
AppData<MyEntity>.DeleteRequest req = testData.DeleteBlocking (someID);

RestRequest restReq = req.BuildRestRequest ();
Assert.True (restReq.Method == Method.DELETE);
Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.UrlSegment;
}).Count >= 1);

Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
return p.Type == ParameterType.HttpHeader;
}).Count >= 3);

}


}
}

6 changes: 6 additions & 0 deletions LibTester/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LinqExtender" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
<package id="NUnit" version="2.6.3" targetFramework="net45" />
</packages>
Loading

0 comments on commit 988336a

Please sign in to comment.