Skip to content

Commit 244e953

Browse files
authored
Merge pull request #72 from cnblogs/improve-tests
Improve tests
2 parents ad96952 + ec8c41e commit 244e953

15 files changed

+88
-60
lines changed

Enyim.Caching/IMemcachedClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public interface IMemcachedClient : IDisposable
2828
CasResult<object> GetWithCas(string key);
2929
CasResult<T> GetWithCas<T>(string key);
3030
IDictionary<string, CasResult<object>> GetWithCas(IEnumerable<string> keys);
31+
Task<IDictionary<string, CasResult<object>>> GetWithCasAsync(IEnumerable<string> keys);
3132

3233
bool Append(string key, ArraySegment<byte> data);
3334
CasResult<bool> Append(string key, ulong cas, ArraySegment<byte> data);

Enyim.Caching/Memcached/MemcachedNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public bool Ping()
9696
if (this.isDisposed) return false;
9797

9898
// try to connect to the server
99-
using (var socket = this.CreateSocket()) ;
99+
using (var socket = this.CreateSocket());
100100

101101
if (this.internalPoolImpl.IsAlive)
102102
return true;

Enyim.Caching/Memcached/Protocol/Binary/MultiGetOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ protected internal override IList<ArraySegment<byte>> GetBuffer()
7575
private bool? asyncLoopState;
7676
private Action<bool> afterAsyncRead;
7777

78-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
78+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
7979
{
80-
return ReadResponse(socket);
80+
return new ValueTask<IOperationResult>(ReadResponse(socket));
8181
}
8282

8383
protected internal override bool ReadResponseAsync(PooledSocket socket, Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/DeleteOperation.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ protected internal override IOperationResult ReadResponse(PooledSocket socket)
2424
};
2525
}
2626

27-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
27+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
2828
{
29-
return new TextOperationResult
30-
{
31-
Success = String.Compare(TextSocketHelper.ReadResponse(socket), "DELETED", StringComparison.Ordinal) == 0
32-
};
29+
return new ValueTask<IOperationResult>(
30+
new TextOperationResult
31+
{
32+
Success = String.Compare(TextSocketHelper.ReadResponse(socket), "DELETED", StringComparison.Ordinal) == 0
33+
});
3334
}
3435

3536
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/FlushOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ protected internal override IOperationResult ReadResponse(PooledSocket socket)
2020
return new TextOperationResult().Pass();
2121
}
2222

23-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
23+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
2424
{
2525
TextSocketHelper.ReadResponse(socket);
26-
return new TextOperationResult().Pass();
26+
return new ValueTask<IOperationResult>(new TextOperationResult().Pass());
2727
}
2828

2929
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/GetOperation.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,19 @@ CacheItem IGetOperation.Result
3737
get { return this.result; }
3838
}
3939

40-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
40+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
4141
{
4242
GetResponse r = GetHelper.ReadItem(socket);
4343
var result = new TextOperationResult();
4444

45-
if (r == null) return result.Fail("Failed to read response");
45+
if (r == null) return new ValueTask<IOperationResult>(result.Fail("Failed to read response"));
4646

4747
this.result = r.Item;
4848
this.Cas = r.CasValue;
4949

5050
GetHelper.FinishCurrent(socket);
5151

52-
return result.Pass();
52+
return new ValueTask<IOperationResult>(result.Pass());
5353
}
5454

5555
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/MultiGetOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Dictionary<string, CacheItem> IMultiGetOperation.Result
6262
get { return this.result; }
6363
}
6464

65-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
65+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
6666
{
6767
var retval = new Dictionary<string, CacheItem>();
6868
var cas = new Dictionary<string, ulong>();
@@ -91,7 +91,7 @@ protected internal override async ValueTask<IOperationResult> ReadResponseAsync(
9191
this.result = retval;
9292
this.Cas = cas;
9393

94-
return new TextOperationResult().Pass();
94+
return new ValueTask<IOperationResult>(new TextOperationResult().Pass());
9595
}
9696

9797
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/MutatorOperation.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ ulong IMutatorOperation.Result
6161
get { return this.result; }
6262
}
6363

64-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
65-
{
64+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
65+
{
6666
string response = TextSocketHelper.ReadResponse(socket);
6767
var result = new TextOperationResult();
6868

6969
//maybe we should throw an exception when the item is not found?
7070
if (String.Compare(response, "NOT_FOUND", StringComparison.Ordinal) == 0)
71-
return result.Fail("Failed to read response. Item not found");
71+
return new ValueTask<IOperationResult>(result.Fail("Failed to read response. Item not found"));
7272

7373
result.Success =
7474
UInt64.TryParse(response, NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out this.result);
75-
return result;
75+
return new ValueTask<IOperationResult>(result);
7676
}
7777

7878
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/StatsOperation.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Dictionary<string, string> IStatsOperation.Result
7373
get { return result; }
7474
}
7575

76-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
76+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
7777
{
7878
var serverData = new Dictionary<string, string>();
7979

@@ -110,7 +110,7 @@ protected internal override async ValueTask<IOperationResult> ReadResponseAsync(
110110

111111
this.result = serverData;
112112

113-
return new TextOperationResult().Pass();
113+
return new ValueTask<IOperationResult>(new TextOperationResult().Pass());
114114
}
115115

116116
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

Enyim.Caching/Memcached/Protocol/Text/StoreOperationBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ protected internal override IOperationResult ReadResponse(PooledSocket socket)
7474
};
7575
}
7676

77-
protected internal override async ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
77+
protected internal override ValueTask<IOperationResult> ReadResponseAsync(PooledSocket socket)
7878
{
79-
return new TextOperationResult
79+
return new ValueTask<IOperationResult>(new TextOperationResult
8080
{
8181
Success = String.Compare(TextSocketHelper.ReadResponse(socket), "STORED", StringComparison.Ordinal) == 0
82-
};
82+
});
8383
}
8484

8585
protected internal override bool ReadResponseAsync(PooledSocket socket, System.Action<bool> next)

0 commit comments

Comments
 (0)