* AVIMConversationQuery.cs: chore

* Utils.cs:
* FileTest.cs:
* JsonTest.cs:
* JustTest.cs:
* RoleTest.cs:
* UserTest.cs:
* QueryTest.cs:
* AVQuery.cs:
* ObjectTest.cs:
* RelationTest.cs:
* SubClassTest.cs:
* AppRouterTest.cs:
* CloudFunctionTest.cs:
* ObjectControllerTests.cs:
* AVObjectController.cs:
oneRain 2019-09-17 11:53:28 +08:00
parent 3f57be22a2
commit 0aab4b959b
16 changed files with 28 additions and 59 deletions

View File

@ -24,19 +24,7 @@ namespace LeanCloud.Realtime
bool compact; bool compact;
bool withLastMessageRefreshed; bool withLastMessageRefreshed;
private AVIMConversationQuery(AVIMConversationQuery source,
IDictionary<string, object> where = null,
IEnumerable<string> replacementOrderBy = null,
IEnumerable<string> thenBy = null,
int? skip = null,
int? limit = null,
IEnumerable<string> includes = null,
IEnumerable<string> selectedKeys = null,
string redirectClassNameForKey = null)
: base(source, where, replacementOrderBy, thenBy, skip, limit, includes, selectedKeys, redirectClassNameForKey)
{
}
/// <summary> /// <summary>
/// Creates the instance. /// Creates the instance.
@ -108,7 +96,7 @@ namespace LeanCloud.Realtime
return cmd; return cmd;
} }
public override Task<int> CountAsync(CancellationToken cancellationToken = default) { public Task<int> CountAsync(CancellationToken cancellationToken = default) {
var convCmd = GenerateQueryCommand(); var convCmd = GenerateQueryCommand();
convCmd.Count(); convCmd.Count();
convCmd.Limit(0); convCmd.Limit(0);
@ -131,7 +119,7 @@ namespace LeanCloud.Realtime
/// </summary> /// </summary>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
public override Task<IEnumerable<AVIMConversation>> FindAsync(CancellationToken cancellationToken = default) public Task<IEnumerable<AVIMConversation>> FindAsync(CancellationToken cancellationToken = default)
{ {
var convCmd = this.GenerateQueryCommand().Option("query"); var convCmd = this.GenerateQueryCommand().Option("query");
return CurrentClient.RunCommandAsync(convCmd).OnSuccess(t => return CurrentClient.RunCommandAsync(convCmd).OnSuccess(t =>
@ -156,12 +144,12 @@ namespace LeanCloud.Realtime
}); });
} }
public override Task<AVIMConversation> FirstAsync(CancellationToken cancellationToken = default) public Task<AVIMConversation> FirstAsync(CancellationToken cancellationToken = default)
{ {
return this.FirstOrDefaultAsync(); return this.FirstOrDefaultAsync();
} }
public override Task<AVIMConversation> FirstOrDefaultAsync(CancellationToken cancellationToken = default) public Task<AVIMConversation> FirstOrDefaultAsync(CancellationToken cancellationToken = default)
{ {
var firstQuery = this.Limit(1); var firstQuery = this.Limit(1);
return firstQuery.FindAsync().OnSuccess(t => return firstQuery.FindAsync().OnSuccess(t =>
@ -170,7 +158,7 @@ namespace LeanCloud.Realtime
}); });
} }
public override Task<AVIMConversation> GetAsync(string objectId, CancellationToken cancellationToken = default) public Task<AVIMConversation> GetAsync(string objectId, CancellationToken cancellationToken = default)
{ {
var idQuery = this.WhereEqualTo("objectId", objectId); var idQuery = this.WhereEqualTo("objectId", objectId);
return idQuery.FirstAsync(); return idQuery.FirstAsync();

View File

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using LeanCloud.Storage.Internal; using LeanCloud.Storage.Internal;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class AppRouterTest { public class AppRouterTest {
[Test] [Test]
public async Task GetServers() { public async Task GetServers() {

View File

@ -3,7 +3,7 @@ using LeanCloud;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class CloudFunctionTest { public class CloudFunctionTest {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {

View File

@ -4,7 +4,7 @@ using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class FileTest { public class FileTest {
string saveFileId; string saveFileId;

View File

@ -5,7 +5,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using LeanCloud.Storage.Internal; using LeanCloud.Storage.Internal;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class JsonTest { public class JsonTest {
[Test] [Test]
public void Deserialize() { public void Deserialize() {

View File

@ -1,5 +1,6 @@
using System; using System;
namespace Storage.Test {
namespace LeanCloud.Test {
public class JustTest { public class JustTest {
public class Animal { public class Animal {

View File

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using LeanCloud; using LeanCloud;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class ObjectControllerTests { public class ObjectControllerTests {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {

View File

@ -3,7 +3,7 @@ using LeanCloud;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class ObjectTests { public class ObjectTests {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {

View File

@ -3,9 +3,8 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Linq; using System.Linq;
using Newtonsoft.Json; using Newtonsoft.Json;
using LeanCloud;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class QueryTest { public class QueryTest {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {

View File

@ -4,7 +4,7 @@ using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class RelationTest { public class RelationTest {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using LeanCloud; using LeanCloud;
namespace LeanCloudTests { namespace LeanCloud.Test {
[TestFixture] [TestFixture]
public class RoleTest { public class RoleTest {
[SetUp] [SetUp]

View File

@ -3,7 +3,7 @@ using LeanCloud;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Collections.Generic; using System.Collections.Generic;
namespace LeanCloudTests { namespace LeanCloud.Test {
[AVClassName("Account")] [AVClassName("Account")]
public class Account : AVObject { public class Account : AVObject {
[AVFieldName("name")] [AVFieldName("name")]

View File

@ -5,7 +5,7 @@ using System.Linq;
using System; using System;
using LeanCloud; using LeanCloud;
namespace LeanCloudTests { namespace LeanCloud.Test {
public class UserTest { public class UserTest {
[SetUp] [SetUp]
public void SetUp() { public void SetUp() {

View File

@ -2,7 +2,7 @@
using LeanCloud; using LeanCloud;
using NUnit.Framework; using NUnit.Framework;
namespace LeanCloudTests { namespace LeanCloud.Test {
public static class Utils { public static class Utils {
public static void InitNorthChina(bool master = false) { public static void InitNorthChina(bool master = false) {
if (master) { if (master) {

View File

@ -37,7 +37,7 @@ namespace LeanCloud.Storage.Internal {
args.Add("fetchWhenSave", fetchWhenSave); args.Add("fetchWhenSave", fetchWhenSave);
} }
// 查询条件 // 查询条件
if (query != null && query.condition != null) { if (query != null) {
args.Add("where", query.BuildWhere()); args.Add("where", query.BuildWhere());
} }
if (args.Count > 0) { if (args.Count > 0) {

View File

@ -28,7 +28,10 @@ namespace LeanCloud {
} }
} }
internal QueryCompositionalCondition condition; /// <summary>
/// 根查询条件,默认是 and 查询,可以设置为 or 查询
/// </summary>
QueryCompositionalCondition condition;
static AVQueryController QueryController { static AVQueryController QueryController {
get { get {
@ -48,7 +51,7 @@ namespace LeanCloud {
condition = new QueryCompositionalCondition(); condition = new QueryCompositionalCondition();
} }
#region Composition #region Compositional Query
public static AVQuery<T> And(IEnumerable<AVQuery<T>> queries) { public static AVQuery<T> And(IEnumerable<AVQuery<T>> queries) {
AVQuery<T> composition = new AVQuery<T>(); AVQuery<T> composition = new AVQuery<T>();
@ -123,6 +126,7 @@ namespace LeanCloud {
} }
#region CQL #region CQL
/// <summary> /// <summary>
/// 执行 CQL 查询 /// 执行 CQL 查询
/// </summary> /// </summary>
@ -166,27 +170,6 @@ namespace LeanCloud {
#endregion #endregion
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
/// <param name="obj">The object to compare with the current object.</param>
/// <returns><c>true</c> if the specified object is equal to the current object; otherwise, <c>false</c></returns>
public override bool Equals(object obj) {
if (obj == null || !(obj is AVQuery<T>)) {
return false;
}
var other = obj as AVQuery<T>;
return ClassName.Equals(other.ClassName) &&
condition.Equals(other.condition);
}
public override int GetHashCode() {
return base.GetHashCode();
}
#region Order By
public AVQuery<T> OrderBy(string key) { public AVQuery<T> OrderBy(string key) {
condition.OrderBy(key); condition.OrderBy(key);
return this; return this;
@ -197,8 +180,6 @@ namespace LeanCloud {
return this; return this;
} }
#endregion
public AVQuery<T> Include(string key) { public AVQuery<T> Include(string key) {
condition.Include(key); condition.Include(key);
return this; return this;
@ -355,7 +336,7 @@ namespace LeanCloud {
#endregion #endregion
internal IDictionary<string, object> BuildParameters(string className = null) { public IDictionary<string, object> BuildParameters(string className = null) {
return condition.BuildParameters(className); return condition.BuildParameters(className);
} }