Skip to content

Commit

Permalink
starting integration tests and updating dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
edatkinvey committed Jan 13, 2015
1 parent 4485dbf commit 44e663a
Show file tree
Hide file tree
Showing 161 changed files with 156 additions and 59,772 deletions.
1 change: 1 addition & 0 deletions Android-Libtester/Android-Libtester.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<Compile Include="ReflectionHelper.cs" />
<Compile Include="LinqBuilderTest.cs" />
<Compile Include="MyEntity.cs" />
<Compile Include="TestIntAppData.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\AboutResources.txt" />
Expand Down
6 changes: 6 additions & 0 deletions Android-Libtester/MyEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ namespace AndroidLibtester
public class MyEntity
{

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

public MyEntity(){}

public string ID {get; set;}


Expand Down
19 changes: 19 additions & 0 deletions Android-Libtester/TestAppData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,25 @@ public void TestSaveEntity()

}

[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);

}


}
}

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

namespace AndroidLibtester
{
[TestFixture]
public class TestIntAppData
{

private string kid = "kid_-yHYO8aYY";
private string secret = "4c2f4856a6c54573b9fccd05c293a58e";
private string collection = "TestData";
private string someID = "test";

private Client client;
private AsyncAppData<MyEntity> appData;

[SetUp]
public void Setup ()
{
client = new Client.Builder (kid, secret).build ();
appData = client.AppData<MyEntity> (collection, typeof(MyEntity));

}


[Test()]
public async void TestSaveEntity()
{
MyEntity ent = new MyEntity ();
ent.Email = "[email protected]";
ent.IsAvailable = true;
ent.lowercasetest = "UpperCase";
ent.Name = "James Dean";

MyEntity saved = await appData.SaveAsync (ent);

Assert.Equals (ent.Name, saved.Name);
Assert.Equals (ent.lowercasetest, saved.lowercasetest);
Assert.Equals (ent.IsAvailable, saved.IsAvailable);
Assert.Equals (ent.Email, saved.Email);
}

[Test()]
public async void TestGetEntity(){
await appData.SaveAsync (new MyEntity (someID));

MyEntity ret = await appData.GetEntityAsync (someID);

Assert.Equals (ret.ID, someID);

}




}
}

1 change: 0 additions & 1 deletion Android-Libtester/TestUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void TestImplicitLogin()
KinveyAuthRequest.LoginType lgType = (KinveyAuthRequest.LoginType) ReflectionHelper.getFieldValue (req, "type");
User memberUser = (User) ReflectionHelper.getFieldValue(req, "memberUser");

// Assert.Equals (lgType, Kinvey.DotNet.Framework.Auth.KinveyAuthRequest.LoginType.IMPLICIT);
Assert.True(lgType == KinveyAuthRequest.LoginType.IMPLICIT);
Assert.That (ReferenceEquals (memberUser, testUser));

Expand Down
2 changes: 1 addition & 1 deletion Kinvey-Xamarin.sln
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,6 @@ Global
{BA2352E1-CB07-4795-A2EB-F70720B2BBC9}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = Kinvey-Xamarin\Kinvey-Xamarin.csproj
StartupItem = Android-Libtester\Android-Libtester.csproj
EndGlobalSection
EndGlobal
22 changes: 19 additions & 3 deletions Kinvey-Xamarin.userprefs
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
<Properties>
<Properties StartupItem="Android-Libtester/Android-Libtester.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Android.Nexus 5 (KitKat)" />
<MonoDevelop.Ide.Workbench />
<MonoDevelop.Ide.Workbench ActiveDocument="Kinvey-Xamarin/Model/ThirdPartyIdentity.cs">
<Files>
<File FileName="Android-Libtester/TestAppData.cs" Line="1" Column="1" />
<File FileName="Android-Libtester/MainActivity.cs" Line="35" Column="35" />
<File FileName="Android-Libtester/LinqBuilderTest.cs" Line="1" Column="1" />
<File FileName="Android-Libtester/TestClient.cs" Line="1" Column="1" />
<File FileName="Android-Libtester/TestUser.cs" Line="1" Column="1" />
<File FileName="Kinvey-Xamarin/File.cs" Line="57" Column="57" />
<File FileName="Kinvey-Xamarin/File/KinveyFileRequest.cs" Line="19" Column="19" />
<File FileName="RestSharp.Portable/RestRequest.cs" Line="35" Column="35" />
<File FileName="RestSharp.Portable/HttpConverter.cs" Line="22" Column="22" />
<File FileName="RestSharp.Portable/HttpRequest.cs" Line="37" Column="37" />
<File FileName="RestSharp.Portable/HttpFile.cs" Line="2" Column="2" />
<File FileName="RestSharp.Portable/DefaultRequestMessage.cs" Line="63" Column="63" />
<File FileName="Kinvey-Xamarin/Model/ThirdPartyIdentity.cs" Line="53" Column="53" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore>
<Breakpoint file="/Users/edwardflemingiii/Projects/Kinvey-Xamarin/Kinvey-Xamarin/Offline/SQLiteHelper.cs" line="150" column="1" />
Expand Down Expand Up @@ -33,7 +49,7 @@
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestClient.cs" line="29" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="21" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="35" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="49" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="48" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-TestDrive/MainActivity.cs" line="73" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Kinvey-Xamarin/Async/AsyncAppData.cs" line="107" column="1" />
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-StatusShare/src.fragments/LoginFragment.cs" line="67" column="1" />
Expand Down
12 changes: 11 additions & 1 deletion Kinvey-Xamarin/AbstractClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public User User()
{
var appKey = ((KinveyClientRequestInitializer)this.RequestInitializer).AppKey;
var appSecret = ((KinveyClientRequestInitializer)this.RequestInitializer).AppSecret;
this.currentUser = new User(this, new KinveyAuthRequest.Builder(this, this.BaseUrl, appKey, appSecret, null));
this.currentUser = new User(this, new KinveyAuthRequest.Builder(this, appKey, appSecret, null));
}
return currentUser;
}
Expand Down Expand Up @@ -115,6 +115,16 @@ public File File()
return new File (this);

}

/// <summary>
/// Execute custom endpoints
/// </summary>
/// <returns>A configured instance of the Custom Endpoint object.</returns>
/// <typeparam name="I">The Type of the input.</typeparam>
/// <typeparam name="O">The Type of the output.</typeparam>
public CustomEndpoint<I, O> CustomEndpoint<I, O>(){
return new CustomEndpoint<I, O> (this);
}

/// <summary>
/// Gets or sets the current user.
Expand Down
12 changes: 11 additions & 1 deletion Kinvey-Xamarin/Async/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected Client(RestClient client, string rootUrl, string servicePath, KinveyCl
if (user == null) {
var appKey = ((KinveyClientRequestInitializer)this.RequestInitializer).AppKey;
var appSecret = ((KinveyClientRequestInitializer)this.RequestInitializer).AppSecret;
this.user = new AsyncUser(this, new KinveyAuthRequest.Builder(this, this.BaseUrl, appKey, appSecret, null));
this.user = new AsyncUser(this, new KinveyAuthRequest.Builder(this, appKey, appSecret, null));
}

return user;
Expand All @@ -87,6 +87,12 @@ protected Client(RestClient client, string rootUrl, string servicePath, KinveyCl
return new AsyncFile (this);
}

/// <summary>
/// Execute custom endpoints
/// </summary>
/// <returns>A configured instance of the Custom Endpoint object.</returns>
/// <typeparam name="I">The Type of the input.</typeparam>
/// <typeparam name="O">The Type of the output.</typeparam>
public new AsyncCustomEndpoint<I, O> CustomEndpoint<I, O>(){
return new AsyncCustomEndpoint<I, O> (this);
}
Expand All @@ -102,6 +108,10 @@ public void Ping(KinveyDelegate<PingResponse> delegates){
});
}

public async Task<PingResponse> PingAsync(){
return await base.pingBlocking().ExecuteAsync();
}


/// <summary>
/// Builder for creating a new instance of a client. Use this class to easily create a new client, as it uses the builder pattern so methods can be chained together.
Expand Down
37 changes: 10 additions & 27 deletions Kinvey-Xamarin/Auth/KinveyAuthRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ private class AuthRequestPayload
/// The RestSharp client
/// </summary>
private AbstractKinveyClient client;
/// <summary>
/// The base URL of the request.
/// </summary>
private string BaseUrl;

/// <summary>
/// The URI template parameters.
/// </summary>
Expand Down Expand Up @@ -91,18 +88,16 @@ private class AuthRequestPayload
/// Initializes a new instance of the <see cref="KinveyXamarin.KinveyAuthRequest"/> class.
/// </summary>
/// <param name="client">Client.</param>
/// <param name="baseUrl">Base URL.</param>
/// <param name="auth">authenticator to use.</param>
/// <param name="appKey">App key.</param>
/// <param name="username">Username.</param>
/// <param name="password">Password.</param>
/// <param name="user">User.</param>
/// <param name="create">If set to <c>true</c> create.</param>
public KinveyAuthRequest(AbstractKinveyClient client, string baseUrl, HttpBasicAuthenticator auth, string appKey, string username, string password, User user, bool create)
public KinveyAuthRequest(AbstractKinveyClient client, HttpBasicAuthenticator auth, string appKey, string username, string password, User user, bool create)

{
this.client = client;
this.BaseUrl = baseUrl;
this.appKeyAuthentication = auth;
if (username != null && password != null) {
this.requestPayload = new JObject ();
Expand All @@ -128,11 +123,10 @@ public KinveyAuthRequest(AbstractKinveyClient client, string baseUrl, HttpBasicA
/// <param name="identity">The third party identity.</param>
/// <param name="user">User.</param>
/// <param name="create">If set to <c>true</c> create.</param>
public KinveyAuthRequest(AbstractKinveyClient client, string baseUrl, HttpBasicAuthenticator auth, string appKey, ThirdPartyIdentity identity, User user, bool create)
public KinveyAuthRequest(AbstractKinveyClient client, HttpBasicAuthenticator auth, string appKey, ThirdPartyIdentity identity, User user, bool create)

{
this.client = client;
this.BaseUrl = baseUrl;
this.appKeyAuthentication = auth;
this.identity = identity;
if (user != null)
Expand Down Expand Up @@ -274,7 +268,6 @@ public class Builder

private string password;

private string baseUrl;

private string appKey;

Expand All @@ -288,10 +281,9 @@ public class Builder
/// <param name="appKey">App key.</param>
/// <param name="appSecret">App secret.</param>
/// <param name="user">User.</param>
public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, string appSecret, User user)
public Builder(AbstractKinveyClient transport, string appKey, string appSecret, User user)
{
this.client = transport;
this.baseUrl = BaseUrl;
this.appKeyAuthentication = new HttpBasicAuthenticator(appKey, appSecret);
this.appKey = appKey;
this.user = user;
Expand All @@ -307,16 +299,16 @@ public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, st
/// <param name="username">Username.</param>
/// <param name="password">Password.</param>
/// <param name="user">User.</param>
public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, string appSecret, string username, string password, User user)
: this(transport, BaseUrl, appKey, appSecret, user)
public Builder(AbstractKinveyClient transport, string appKey, string appSecret, string username, string password, User user)
: this(transport, appKey, appSecret, user)
{
this.username = username;
this.password = password;
}


public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, string appSecret, ThirdPartyIdentity identity, User user)
: this(transport, BaseUrl, appKey, appSecret, user)
public Builder(AbstractKinveyClient transport, string appKey, string appSecret, ThirdPartyIdentity identity, User user)
: this(transport, appKey, appSecret, user)
{
this.identity = identity;

Expand All @@ -329,9 +321,9 @@ public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, st
public KinveyAuthRequest build()
{
if (identity == null) {
return new KinveyAuthRequest (Client, BaseUrl, AppKeyAuthentication, AppKey, Username, Password, KinveyUser, this.create);
return new KinveyAuthRequest (Client, AppKeyAuthentication, AppKey, Username, Password, KinveyUser, this.create);
} else {
return new KinveyAuthRequest (Client, BaseUrl, AppKeyAuthentication, AppKey, identity, KinveyUser, this.create);
return new KinveyAuthRequest (Client, AppKeyAuthentication, AppKey, identity, KinveyUser, this.create);
}
}

Expand Down Expand Up @@ -399,15 +391,6 @@ public HttpBasicAuthenticator AppKeyAuthentication
get { return appKeyAuthentication; }
}

/// <summary>
/// Gets the base URL.
/// </summary>
/// <value>The base URL.</value>
public string BaseUrl
{
get { return baseUrl; }
}

/// <summary>
/// Gets or sets the app key.
/// </summary>
Expand Down
24 changes: 12 additions & 12 deletions Kinvey-Xamarin/Kinvey-Xamarin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,9 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="LinqExtender">
<HintPath>..\packages\LinqExtender.3.0.1\lib\LinqExtender.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net.Async">
<HintPath>..\packages\SQLite.Net.Async-PCL.2.4.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net">
<HintPath>..\packages\SQLite.Net-PCL.2.4.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Newtonsoft.Json.dll</HintPath>
</Reference>
Expand All @@ -130,6 +118,18 @@
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net">
<HintPath>..\packages\SQLite.Net-PCL.2.5\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
</Reference>
<Reference Include="SQLite.Net.Async">
<HintPath>..\packages\SQLite.Net.Async-PCL.2.5\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RestSharp.Portable\RestSharp.Portable.csproj">
Expand Down
5 changes: 0 additions & 5 deletions Kinvey-Xamarin/Offline/AbstractKinveyOfflineClientRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ public class AbstractKinveyOfflineClientRequest<T> : AbstractKinveyClientRequest
/// </summary>
private OfflinePolicy policy = OfflinePolicy.ALWAYS_ONLINE;

/// <summary>
/// The lock for database access
/// </summary>
private Object locker = new Object();

/// <summary>
/// The name of the collection.
/// </summary>
Expand Down
Loading

0 comments on commit 44e663a

Please sign in to comment.