Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 44e663a

Browse files
committed
starting integration tests and updating dependencies.
1 parent 4485dbf commit 44e663a

File tree

161 files changed

+156
-59772
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

161 files changed

+156
-59772
lines changed

Android-Libtester/Android-Libtester.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
<Compile Include="ReflectionHelper.cs" />
6161
<Compile Include="LinqBuilderTest.cs" />
6262
<Compile Include="MyEntity.cs" />
63+
<Compile Include="TestIntAppData.cs" />
6364
</ItemGroup>
6465
<ItemGroup>
6566
<None Include="Resources\AboutResources.txt" />

Android-Libtester/MyEntity.cs

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ namespace AndroidLibtester
77
public class MyEntity
88
{
99

10+
public MyEntity(string id){
11+
this.ID = id;
12+
}
13+
14+
public MyEntity(){}
15+
1016
public string ID {get; set;}
1117

1218

Android-Libtester/TestAppData.cs

+19
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,25 @@ public void TestSaveEntity()
8585

8686
}
8787

88+
[Test()]
89+
public void TestDeleteEntity()
90+
{
91+
string someID = "some id";
92+
AppData<MyEntity>.DeleteRequest req = testData.DeleteBlocking (someID);
93+
94+
RestRequest restReq = req.BuildRestRequest ();
95+
Assert.True (restReq.Method == Method.DELETE);
96+
Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
97+
return p.Type == ParameterType.UrlSegment;
98+
}).Count >= 1);
99+
100+
Assert.True (restReq.Parameters.FindAll (delegate(Parameter p){
101+
return p.Type == ParameterType.HttpHeader;
102+
}).Count >= 3);
103+
104+
}
105+
106+
88107
}
89108
}
90109

Android-Libtester/TestIntAppData.cs

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System;
2+
using NUnit.Framework;
3+
using KinveyXamarin;
4+
using System.Reflection;
5+
using RestSharp;
6+
using LinqExtender;
7+
8+
namespace AndroidLibtester
9+
{
10+
[TestFixture]
11+
public class TestIntAppData
12+
{
13+
14+
private string kid = "kid_-yHYO8aYY";
15+
private string secret = "4c2f4856a6c54573b9fccd05c293a58e";
16+
private string collection = "TestData";
17+
private string someID = "test";
18+
19+
private Client client;
20+
private AsyncAppData<MyEntity> appData;
21+
22+
[SetUp]
23+
public void Setup ()
24+
{
25+
client = new Client.Builder (kid, secret).build ();
26+
appData = client.AppData<MyEntity> (collection, typeof(MyEntity));
27+
28+
}
29+
30+
31+
[Test()]
32+
public async void TestSaveEntity()
33+
{
34+
MyEntity ent = new MyEntity ();
35+
ent.Email = "[email protected]";
36+
ent.IsAvailable = true;
37+
ent.lowercasetest = "UpperCase";
38+
ent.Name = "James Dean";
39+
40+
MyEntity saved = await appData.SaveAsync (ent);
41+
42+
Assert.Equals (ent.Name, saved.Name);
43+
Assert.Equals (ent.lowercasetest, saved.lowercasetest);
44+
Assert.Equals (ent.IsAvailable, saved.IsAvailable);
45+
Assert.Equals (ent.Email, saved.Email);
46+
}
47+
48+
[Test()]
49+
public async void TestGetEntity(){
50+
await appData.SaveAsync (new MyEntity (someID));
51+
52+
MyEntity ret = await appData.GetEntityAsync (someID);
53+
54+
Assert.Equals (ret.ID, someID);
55+
56+
}
57+
58+
59+
60+
61+
}
62+
}
63+

Android-Libtester/TestUser.cs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public void TestImplicitLogin()
3737
KinveyAuthRequest.LoginType lgType = (KinveyAuthRequest.LoginType) ReflectionHelper.getFieldValue (req, "type");
3838
User memberUser = (User) ReflectionHelper.getFieldValue(req, "memberUser");
3939

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

Kinvey-Xamarin.sln

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,6 @@ Global
9696
{BA2352E1-CB07-4795-A2EB-F70720B2BBC9}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
9797
EndGlobalSection
9898
GlobalSection(MonoDevelopProperties) = preSolution
99-
StartupItem = Kinvey-Xamarin\Kinvey-Xamarin.csproj
99+
StartupItem = Android-Libtester\Android-Libtester.csproj
100100
EndGlobalSection
101101
EndGlobal

Kinvey-Xamarin.userprefs

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
1-
<Properties>
1+
<Properties StartupItem="Android-Libtester/Android-Libtester.csproj">
22
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Android.Nexus 5 (KitKat)" />
3-
<MonoDevelop.Ide.Workbench />
3+
<MonoDevelop.Ide.Workbench ActiveDocument="Kinvey-Xamarin/Model/ThirdPartyIdentity.cs">
4+
<Files>
5+
<File FileName="Android-Libtester/TestAppData.cs" Line="1" Column="1" />
6+
<File FileName="Android-Libtester/MainActivity.cs" Line="35" Column="35" />
7+
<File FileName="Android-Libtester/LinqBuilderTest.cs" Line="1" Column="1" />
8+
<File FileName="Android-Libtester/TestClient.cs" Line="1" Column="1" />
9+
<File FileName="Android-Libtester/TestUser.cs" Line="1" Column="1" />
10+
<File FileName="Kinvey-Xamarin/File.cs" Line="57" Column="57" />
11+
<File FileName="Kinvey-Xamarin/File/KinveyFileRequest.cs" Line="19" Column="19" />
12+
<File FileName="RestSharp.Portable/RestRequest.cs" Line="35" Column="35" />
13+
<File FileName="RestSharp.Portable/HttpConverter.cs" Line="22" Column="22" />
14+
<File FileName="RestSharp.Portable/HttpRequest.cs" Line="37" Column="37" />
15+
<File FileName="RestSharp.Portable/HttpFile.cs" Line="2" Column="2" />
16+
<File FileName="RestSharp.Portable/DefaultRequestMessage.cs" Line="63" Column="63" />
17+
<File FileName="Kinvey-Xamarin/Model/ThirdPartyIdentity.cs" Line="53" Column="53" />
18+
</Files>
19+
</MonoDevelop.Ide.Workbench>
420
<MonoDevelop.Ide.DebuggingService.Breakpoints>
521
<BreakpointStore>
622
<Breakpoint file="/Users/edwardflemingiii/Projects/Kinvey-Xamarin/Kinvey-Xamarin/Offline/SQLiteHelper.cs" line="150" column="1" />
@@ -33,7 +49,7 @@
3349
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestClient.cs" line="29" column="1" />
3450
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="21" column="1" />
3551
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="35" column="1" />
36-
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="49" column="1" />
52+
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-Libtester/TestUser.cs" line="48" column="1" />
3753
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-TestDrive/MainActivity.cs" line="73" column="1" />
3854
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Kinvey-Xamarin/Async/AsyncAppData.cs" line="107" column="1" />
3955
<Breakpoint file="/Users/edward/code/klibs/Kinvey-Xamarin/Android-StatusShare/src.fragments/LoginFragment.cs" line="67" column="1" />

Kinvey-Xamarin/AbstractClient.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public User User()
8181
{
8282
var appKey = ((KinveyClientRequestInitializer)this.RequestInitializer).AppKey;
8383
var appSecret = ((KinveyClientRequestInitializer)this.RequestInitializer).AppSecret;
84-
this.currentUser = new User(this, new KinveyAuthRequest.Builder(this, this.BaseUrl, appKey, appSecret, null));
84+
this.currentUser = new User(this, new KinveyAuthRequest.Builder(this, appKey, appSecret, null));
8585
}
8686
return currentUser;
8787
}
@@ -115,6 +115,16 @@ public File File()
115115
return new File (this);
116116

117117
}
118+
119+
/// <summary>
120+
/// Execute custom endpoints
121+
/// </summary>
122+
/// <returns>A configured instance of the Custom Endpoint object.</returns>
123+
/// <typeparam name="I">The Type of the input.</typeparam>
124+
/// <typeparam name="O">The Type of the output.</typeparam>
125+
public CustomEndpoint<I, O> CustomEndpoint<I, O>(){
126+
return new CustomEndpoint<I, O> (this);
127+
}
118128

119129
/// <summary>
120130
/// Gets or sets the current user.

Kinvey-Xamarin/Async/Client.cs

+11-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected Client(RestClient client, string rootUrl, string servicePath, KinveyCl
6060
if (user == null) {
6161
var appKey = ((KinveyClientRequestInitializer)this.RequestInitializer).AppKey;
6262
var appSecret = ((KinveyClientRequestInitializer)this.RequestInitializer).AppSecret;
63-
this.user = new AsyncUser(this, new KinveyAuthRequest.Builder(this, this.BaseUrl, appKey, appSecret, null));
63+
this.user = new AsyncUser(this, new KinveyAuthRequest.Builder(this, appKey, appSecret, null));
6464
}
6565

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

90+
/// <summary>
91+
/// Execute custom endpoints
92+
/// </summary>
93+
/// <returns>A configured instance of the Custom Endpoint object.</returns>
94+
/// <typeparam name="I">The Type of the input.</typeparam>
95+
/// <typeparam name="O">The Type of the output.</typeparam>
9096
public new AsyncCustomEndpoint<I, O> CustomEndpoint<I, O>(){
9197
return new AsyncCustomEndpoint<I, O> (this);
9298
}
@@ -102,6 +108,10 @@ public void Ping(KinveyDelegate<PingResponse> delegates){
102108
});
103109
}
104110

111+
public async Task<PingResponse> PingAsync(){
112+
return await base.pingBlocking().ExecuteAsync();
113+
}
114+
105115

106116
/// <summary>
107117
/// 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.

Kinvey-Xamarin/Auth/KinveyAuthRequest.cs

+10-27
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ private class AuthRequestPayload
5959
/// The RestSharp client
6060
/// </summary>
6161
private AbstractKinveyClient client;
62-
/// <summary>
63-
/// The base URL of the request.
64-
/// </summary>
65-
private string BaseUrl;
62+
6663
/// <summary>
6764
/// The URI template parameters.
6865
/// </summary>
@@ -91,18 +88,16 @@ private class AuthRequestPayload
9188
/// Initializes a new instance of the <see cref="KinveyXamarin.KinveyAuthRequest"/> class.
9289
/// </summary>
9390
/// <param name="client">Client.</param>
94-
/// <param name="baseUrl">Base URL.</param>
9591
/// <param name="auth">authenticator to use.</param>
9692
/// <param name="appKey">App key.</param>
9793
/// <param name="username">Username.</param>
9894
/// <param name="password">Password.</param>
9995
/// <param name="user">User.</param>
10096
/// <param name="create">If set to <c>true</c> create.</param>
101-
public KinveyAuthRequest(AbstractKinveyClient client, string baseUrl, HttpBasicAuthenticator auth, string appKey, string username, string password, User user, bool create)
97+
public KinveyAuthRequest(AbstractKinveyClient client, HttpBasicAuthenticator auth, string appKey, string username, string password, User user, bool create)
10298

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

133128
{
134129
this.client = client;
135-
this.BaseUrl = baseUrl;
136130
this.appKeyAuthentication = auth;
137131
this.identity = identity;
138132
if (user != null)
@@ -274,7 +268,6 @@ public class Builder
274268

275269
private string password;
276270

277-
private string baseUrl;
278271

279272
private string appKey;
280273

@@ -288,10 +281,9 @@ public class Builder
288281
/// <param name="appKey">App key.</param>
289282
/// <param name="appSecret">App secret.</param>
290283
/// <param name="user">User.</param>
291-
public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, string appSecret, User user)
284+
public Builder(AbstractKinveyClient transport, string appKey, string appSecret, User user)
292285
{
293286
this.client = transport;
294-
this.baseUrl = BaseUrl;
295287
this.appKeyAuthentication = new HttpBasicAuthenticator(appKey, appSecret);
296288
this.appKey = appKey;
297289
this.user = user;
@@ -307,16 +299,16 @@ public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, st
307299
/// <param name="username">Username.</param>
308300
/// <param name="password">Password.</param>
309301
/// <param name="user">User.</param>
310-
public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, string appSecret, string username, string password, User user)
311-
: this(transport, BaseUrl, appKey, appSecret, user)
302+
public Builder(AbstractKinveyClient transport, string appKey, string appSecret, string username, string password, User user)
303+
: this(transport, appKey, appSecret, user)
312304
{
313305
this.username = username;
314306
this.password = password;
315307
}
316308

317309

318-
public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, string appSecret, ThirdPartyIdentity identity, User user)
319-
: this(transport, BaseUrl, appKey, appSecret, user)
310+
public Builder(AbstractKinveyClient transport, string appKey, string appSecret, ThirdPartyIdentity identity, User user)
311+
: this(transport, appKey, appSecret, user)
320312
{
321313
this.identity = identity;
322314

@@ -329,9 +321,9 @@ public Builder(AbstractKinveyClient transport, string BaseUrl, string appKey, st
329321
public KinveyAuthRequest build()
330322
{
331323
if (identity == null) {
332-
return new KinveyAuthRequest (Client, BaseUrl, AppKeyAuthentication, AppKey, Username, Password, KinveyUser, this.create);
324+
return new KinveyAuthRequest (Client, AppKeyAuthentication, AppKey, Username, Password, KinveyUser, this.create);
333325
} else {
334-
return new KinveyAuthRequest (Client, BaseUrl, AppKeyAuthentication, AppKey, identity, KinveyUser, this.create);
326+
return new KinveyAuthRequest (Client, AppKeyAuthentication, AppKey, identity, KinveyUser, this.create);
335327
}
336328
}
337329

@@ -399,15 +391,6 @@ public HttpBasicAuthenticator AppKeyAuthentication
399391
get { return appKeyAuthentication; }
400392
}
401393

402-
/// <summary>
403-
/// Gets the base URL.
404-
/// </summary>
405-
/// <value>The base URL.</value>
406-
public string BaseUrl
407-
{
408-
get { return baseUrl; }
409-
}
410-
411394
/// <summary>
412395
/// Gets or sets the app key.
413396
/// </summary>

Kinvey-Xamarin/Kinvey-Xamarin.csproj

+12-12
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,9 @@
103103
<None Include="packages.config" />
104104
</ItemGroup>
105105
<ItemGroup>
106-
<Reference Include="Microsoft.Threading.Tasks">
107-
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.dll</HintPath>
108-
</Reference>
109-
<Reference Include="Microsoft.Threading.Tasks.Extensions">
110-
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
111-
</Reference>
112106
<Reference Include="LinqExtender">
113107
<HintPath>..\packages\LinqExtender.3.0.1\lib\LinqExtender.dll</HintPath>
114108
</Reference>
115-
<Reference Include="SQLite.Net.Async">
116-
<HintPath>..\packages\SQLite.Net.Async-PCL.2.4.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll</HintPath>
117-
</Reference>
118-
<Reference Include="SQLite.Net">
119-
<HintPath>..\packages\SQLite.Net-PCL.2.4.1\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
120-
</Reference>
121109
<Reference Include="Newtonsoft.Json">
122110
<HintPath>..\packages\Newtonsoft.Json.6.0.7\lib\portable-net45+wp80+win8+wpa81+aspnetcore50\Newtonsoft.Json.dll</HintPath>
123111
</Reference>
@@ -130,6 +118,18 @@
130118
<Reference Include="System.Net.Http.Extensions">
131119
<HintPath>..\packages\Microsoft.Net.Http.2.2.28\lib\portable-net40+sl4+win8+wp71+wpa81\System.Net.Http.Extensions.dll</HintPath>
132120
</Reference>
121+
<Reference Include="Microsoft.Threading.Tasks">
122+
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.dll</HintPath>
123+
</Reference>
124+
<Reference Include="Microsoft.Threading.Tasks.Extensions">
125+
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\portable-net45+win8+wp8+wpa81\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
126+
</Reference>
127+
<Reference Include="SQLite.Net">
128+
<HintPath>..\packages\SQLite.Net-PCL.2.5\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.dll</HintPath>
129+
</Reference>
130+
<Reference Include="SQLite.Net.Async">
131+
<HintPath>..\packages\SQLite.Net.Async-PCL.2.5\lib\portable-win8+net45+wp8+wpa81+MonoAndroid1+MonoTouch1\SQLite.Net.Async.dll</HintPath>
132+
</Reference>
133133
</ItemGroup>
134134
<ItemGroup>
135135
<ProjectReference Include="..\RestSharp.Portable\RestSharp.Portable.csproj">

Kinvey-Xamarin/Offline/AbstractKinveyOfflineClientRequest.cs

-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ public class AbstractKinveyOfflineClientRequest<T> : AbstractKinveyClientRequest
3333
/// </summary>
3434
private OfflinePolicy policy = OfflinePolicy.ALWAYS_ONLINE;
3535

36-
/// <summary>
37-
/// The lock for database access
38-
/// </summary>
39-
private Object locker = new Object();
40-
4136
/// <summary>
4237
/// The name of the collection.
4338
/// </summary>

0 commit comments

Comments
 (0)