From 9d48b99534a385a2c4390d07a2d6025a5dba4755 Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Thu, 22 Sep 2022 17:32:14 -0700 Subject: [PATCH 1/8] feat: data response object polymorphism --- src/Momento.Sdk/Internal/ScsDataClient.cs | 38 ++++++--- .../Responses/CacheDeleteResponse.cs | 21 ++++- .../Responses/CacheGetBatchResponse.cs | 76 +++++++++++++---- src/Momento.Sdk/Responses/CacheGetResponse.cs | 46 +++++++++- .../Responses/CacheGetResponseBase.cs | 31 ------- .../Responses/CacheSetBatchResponse.cs | 24 ++++++ src/Momento.Sdk/Responses/CacheSetResponse.cs | 23 +++++ .../Momento.Sdk.Tests/SimpleCacheDataTest.cs | 83 +++++++++++++------ .../Responses/CacheGetResponseTest.cs | 7 +- 9 files changed, 257 insertions(+), 92 deletions(-) delete mode 100644 src/Momento.Sdk/Responses/CacheGetResponseBase.cs diff --git a/src/Momento.Sdk/Internal/ScsDataClient.cs b/src/Momento.Sdk/Internal/ScsDataClient.cs index 692be607..3c6fec0c 100644 --- a/src/Momento.Sdk/Internal/ScsDataClient.cs +++ b/src/Momento.Sdk/Internal/ScsDataClient.cs @@ -115,21 +115,27 @@ public async Task GetBatchAsync(string cacheName, IEnumer } catch (Exception e) { - throw CacheExceptionMapper.Convert(e); + return new CacheGetBatchResponse.Error(CacheExceptionMapper.Convert(e)); } // Handle failures if (continuation.Status == TaskStatus.Faulted) { - throw CacheExceptionMapper.Convert(continuation.Exception); + return new CacheGetBatchResponse.Error( + CacheExceptionMapper.Convert(continuation.Exception) + ); } else if (continuation.Status != TaskStatus.RanToCompletion) { - throw CacheExceptionMapper.Convert(new Exception(String.Format("Failure issuing multi-get: {0}", continuation.Status))); + return new CacheGetBatchResponse.Error( + CacheExceptionMapper.Convert( + new Exception(String.Format("Failure issuing multi-get: {0}", continuation.Status)) + ) + ); } // Package results - return new CacheGetBatchResponse(continuation.Result); + return new CacheGetBatchResponse.Success(continuation.Result); } public async Task SetBatchAsync(string cacheName, IEnumerable> items, uint? ttlSeconds = null) @@ -159,19 +165,27 @@ public async Task SendSetBatchAsync(string cacheName, IEn } catch (Exception e) { - throw CacheExceptionMapper.Convert(e); + return new CacheSetBatchResponse.Error( + CacheExceptionMapper.Convert(e) + ); } // Handle failures if (continuation.Status == TaskStatus.Faulted) { - throw CacheExceptionMapper.Convert(continuation.Exception); + return new CacheSetBatchResponse.Error( + CacheExceptionMapper.Convert(continuation.Exception) + ); } else if (continuation.Status != TaskStatus.RanToCompletion) { - throw CacheExceptionMapper.Convert(new Exception(String.Format("Failure issuing multi-set: {0}", continuation.Status))); + return new CacheSetBatchResponse.Error( + CacheExceptionMapper.Convert( + new Exception(String.Format("Failure issuing multi-set: {0}", continuation.Status)) + ) + ); } - return new CacheSetBatchResponse(); + return new CacheSetBatchResponse.Success(); } private async Task SendSetAsync(string cacheName, ByteString key, ByteString value, uint? ttlSeconds = null) @@ -183,9 +197,9 @@ private async Task SendSetAsync(string cacheName, ByteString k } catch (Exception e) { - throw CacheExceptionMapper.Convert(e); + return new CacheSetResponse.Error(CacheExceptionMapper.Convert(e)); } - return new CacheSetResponse(); + return new CacheSetResponse.Success(); } private async Task SendGetAsync(string cacheName, ByteString key) @@ -198,9 +212,9 @@ private async Task SendGetAsync(string cacheName, ByteString k } catch (Exception e) { - throw CacheExceptionMapper.Convert(e); + return new CacheGetResponse.Error(CacheExceptionMapper.Convert(e)); } - return new CacheGetResponse(response); + return new CacheGetResponse.Success(response); } private async Task SendDeleteAsync(string cacheName, ByteString key) diff --git a/src/Momento.Sdk/Responses/CacheDeleteResponse.cs b/src/Momento.Sdk/Responses/CacheDeleteResponse.cs index 56e1c27f..1686ad49 100644 --- a/src/Momento.Sdk/Responses/CacheDeleteResponse.cs +++ b/src/Momento.Sdk/Responses/CacheDeleteResponse.cs @@ -1,8 +1,27 @@ namespace Momento.Sdk.Responses; +using Momento.Sdk.Exceptions; + public class CacheDeleteResponse { - public CacheDeleteResponse() + public class Success : CacheDeleteResponse { } + + public class Error : CacheDeleteResponse { + private readonly SdkException _error; + public Error(SdkException error) + { + _error = error; + } + + public SdkException Exception + { + get => _error; + } + + public MomentoErrorCode ErrorCode + { + get => _error.ErrorCode; + } } } diff --git a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs index 3597dae3..12c44088 100644 --- a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs @@ -1,29 +1,75 @@ using System.Collections.Generic; -using System.Linq; +using Momento.Sdk.Exceptions; namespace Momento.Sdk.Responses; public class CacheGetBatchResponse { - public List Responses { get; } - - public CacheGetBatchResponse(IEnumerable responses) + public class Success : CacheGetBatchResponse { - this.Responses = new(responses); - } + public List Responses { get; } - public IEnumerable Status - { - get => Responses.Select(response => response.Status); - } + public Success(IEnumerable responses) + { + this.Responses = new(responses); + } - public IEnumerable Strings() - { - return Responses.Select(response => response.String()); + public IEnumerable Status + { + // get => Responses.Select(response => response.Status); + get + { + var ret = new List(); + foreach (CacheGetResponse.Success response in Responses) + { + ret.Add(response.Status); + } + return ret; + } + } + + public IEnumerable Strings() + { + // return Responses.Select(response => response.String()); + var ret = new List(); + foreach (CacheGetResponse.Success response in Responses) + { + ret.Add(response.String()); + } + return ret.ToArray(); + } + + public IEnumerable ByteArrays + { + // get => Responses.Select(response => response.ByteArray); + get + { + var ret = new List(); + foreach (CacheGetResponse.Success response in Responses) + { + ret.Add(response.ByteArray); + } + return ret; + } + } } - public IEnumerable ByteArrays + public class Error : CacheGetBatchResponse { - get => Responses.Select(response => response.ByteArray); + private readonly SdkException _error; + public Error(SdkException error) + { + _error = error; + } + + public SdkException Exception + { + get => _error; + } + + public MomentoErrorCode ErrorCode + { + get => _error.ErrorCode; + } } } diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index f19d9754..8f4647b8 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -1,11 +1,51 @@ using Google.Protobuf; using Momento.Protos.CacheClient; - +using Momento.Sdk.Exceptions; namespace Momento.Sdk.Responses; -public class CacheGetResponse : CacheGetResponseBase +public class CacheGetResponse { - public CacheGetResponse(_GetResponse response) : base(response.Result, response.CacheBody) + public class Success : CacheGetResponse + { + public CacheGetStatus Status { get; } + protected readonly ByteString? value; + + public Success(_GetResponse response) + { + if (response.Result is ECacheResult status) { + Status = CacheGetStatusUtil.From(status); + this.value = response.CacheBody; + } else { + Status = (CacheGetStatus)response.Result; + this.value = (Status == CacheGetStatus.HIT) ? value : null; + } + } + + public byte[]? ByteArray + { + get => value != null ? value.ToByteArray() : null; + } + + public string? String() => (value != null) ? value.ToStringUtf8() : null; + + } + + public class Error : CacheGetResponse { + private readonly SdkException _error; + public Error(SdkException error) + { + _error = error; + } + + public SdkException Exception + { + get => _error; + } + + public MomentoErrorCode ErrorCode + { + get => _error.ErrorCode; + } } } diff --git a/src/Momento.Sdk/Responses/CacheGetResponseBase.cs b/src/Momento.Sdk/Responses/CacheGetResponseBase.cs deleted file mode 100644 index ea07ecac..00000000 --- a/src/Momento.Sdk/Responses/CacheGetResponseBase.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Google.Protobuf; -using Momento.Protos.CacheClient; - -namespace Momento.Sdk.Responses; - -/// -/// Base class encapsulating a state of a key in the cache and its value. -/// Derived classes unpack the values from gRPC response objects in particular ways. -/// -public class CacheGetResponseBase -{ - public CacheGetStatus Status { get; } - protected readonly ByteString? value; - - public CacheGetResponseBase(CacheGetStatus status, ByteString? value) - { - Status = status; - this.value = (Status == CacheGetStatus.HIT) ? value : null; - } - - public CacheGetResponseBase(ECacheResult status, ByteString value) : this(CacheGetStatusUtil.From(status), value) - { - } - - public byte[]? ByteArray - { - get => value != null ? value.ToByteArray() : null; - } - - public string? String() => (value != null) ? value.ToStringUtf8() : null; -} diff --git a/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs index 98cc6ad7..b4484a3e 100644 --- a/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs @@ -1,5 +1,29 @@ namespace Momento.Sdk.Responses; +using Momento.Sdk.Exceptions; + public class CacheSetBatchResponse { + + public class Success : CacheSetBatchResponse { } + + public class Error: CacheSetBatchResponse + { + private readonly SdkException _error; + public Error(SdkException error) + { + _error = error; + } + + public SdkException Exception + { + get => _error; + } + + public MomentoErrorCode ErrorCode + { + get => _error.ErrorCode; + } + } + } diff --git a/src/Momento.Sdk/Responses/CacheSetResponse.cs b/src/Momento.Sdk/Responses/CacheSetResponse.cs index a4682e03..4041ca8f 100644 --- a/src/Momento.Sdk/Responses/CacheSetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetResponse.cs @@ -1,5 +1,28 @@ namespace Momento.Sdk.Responses; +using Momento.Sdk.Exceptions; + public class CacheSetResponse { + + public class Success : CacheSetResponse { } + + public class Error : CacheSetResponse + { + private readonly SdkException _error; + public Error(SdkException error) + { + _error = error; + } + + public SdkException Exception + { + get => _error; + } + + public MomentoErrorCode ErrorCode + { + get => _error.ErrorCode; + } + } } diff --git a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs index ac554ce2..7cc93c41 100644 --- a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs +++ b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs @@ -38,14 +38,20 @@ public async Task SetAsync_KeyIsByteArrayValueIsByteArray_HappyPath() byte[] key = Utils.NewGuidByteArray(); byte[] value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value); - byte[]? setValue = (await client.GetAsync(cacheName, key)).ByteArray; - Assert.Equal(value, setValue); + CacheGetResponse response = await client.GetAsync(cacheName, key); + if (response is CacheGetResponse.Success goodResponse) { + byte[]? setValue = goodResponse.ByteArray; + Assert.Equal(value, setValue); + } key = Utils.NewGuidByteArray(); value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); - setValue = (await client.GetAsync(cacheName, key)).ByteArray; - Assert.Equal(value, setValue); + response = await client.GetAsync(cacheName, key); + if (response is CacheGetResponse.Success anotherGoodResponse) { + byte[]? setValue = anotherGoodResponse.ByteArray; + Assert.Equal(value, setValue); + } } [Theory] @@ -73,14 +79,20 @@ public async Task SetAsync_KeyIsStringValueIsString_HappyPath() string key = Utils.NewGuidString(); string value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value); - string? setValue = (await client.GetAsync(cacheName, key)).String(); - Assert.Equal(value, setValue); + CacheGetResponse response = await client.GetAsync(cacheName, key); + if (response is CacheGetResponse.Success goodResponse) { + string? setValue = goodResponse.String(); + Assert.Equal(value, setValue); + } key = Utils.NewGuidString(); value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); - setValue = (await client.GetAsync(cacheName, key)).String(); - Assert.Equal(value, setValue); + response = await client.GetAsync(cacheName, key); + if (response is CacheGetResponse.Success anotherGoodResponse) { + string? setValue = anotherGoodResponse.String(); + Assert.Equal(value, setValue); + } } [Theory] @@ -108,14 +120,19 @@ public async Task SetAsync_KeyIsStringValueIsByteArray_HappyPath() string key = Utils.NewGuidString(); byte[] value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value); - byte[]? setValue = (await client.GetAsync(cacheName, key)).ByteArray; - Assert.Equal(value, setValue); + CacheGetResponse response = await client.GetAsync(cacheName, key); + if (response is CacheGetResponse.Success goodResponse) { + byte[]? setValue = goodResponse.ByteArray; + Assert.Equal(value, setValue); + } key = Utils.NewGuidString(); value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); - setValue = (await client.GetAsync(cacheName, key)).ByteArray; - Assert.Equal(value, setValue); + response = await client.GetAsync(cacheName, key); + var anotherGoodResponse = (CacheGetResponse.Success)response; + byte[]? anotherSetValue = anotherGoodResponse.ByteArray; + Assert.Equal(value, anotherSetValue); } [Fact] @@ -141,8 +158,9 @@ public async Task GetBatchAsync_KeysAreByteArray_HappyPath() List keys = new() { Utils.Utf8ToByteArray(key1), Utils.Utf8ToByteArray(key2) }; CacheGetBatchResponse result = await client.GetBatchAsync(cacheName, keys); - string? stringResult1 = result.Strings().ToList()[0]; - string? stringResult2 = result.Strings().ToList()[1]; + var goodResult = (CacheGetBatchResponse.Success)result; + string? stringResult1 = goodResult.Strings().ToList()[0]; + string? stringResult2 = goodResult.Strings().ToList()[1]; Assert.Equal(value1, stringResult1); Assert.Equal(value2, stringResult2); } @@ -170,8 +188,9 @@ public async Task GetBatchAsync_KeysAreString_HappyPath() List keys = new() { key1, key2, "key123123" }; CacheGetBatchResponse result = await client.GetBatchAsync(cacheName, keys); - Assert.Equal(result.Strings(), new string[] { value1, value2, null! }); - Assert.Equal(result.Status, new CacheGetStatus[] { CacheGetStatus.HIT, CacheGetStatus.HIT, CacheGetStatus.MISS }); + var goodResult = (CacheGetBatchResponse.Success)result; + Assert.Equal(goodResult.Strings(), new string[] { value1, value2, null! }); + Assert.Equal(goodResult.Status, new CacheGetStatus[] { CacheGetStatus.HIT, CacheGetStatus.HIT, CacheGetStatus.MISS }); } [Fact] @@ -180,7 +199,10 @@ public async Task GetBatchAsync_Failure() // Set very small timeout for dataClientOperationTimeoutMilliseconds using SimpleCacheClient simpleCacheClient = new SimpleCacheClient(Configurations.Laptop.Latest, authToken, DefaultTtlSeconds, 1); List keys = new() { Utils.NewGuidString(), Utils.NewGuidString(), Utils.NewGuidString(), Utils.NewGuidString() }; - await Assert.ThrowsAsync(async () => await simpleCacheClient.GetBatchAsync(cacheName, keys)); + CacheGetBatchResponse response = await simpleCacheClient.GetBatchAsync(cacheName, keys); + if (response is CacheGetBatchResponse.Error badResponse) { + Assert.Equal(MomentoErrorCode.TIMEOUT_ERROR, badResponse.ErrorCode); + } } [Fact] @@ -208,10 +230,12 @@ public async Task SetBatchAsync_ItemsAreByteArray_HappyPath() await client.SetBatchAsync(cacheName, dictionary); var getResponse = await client.GetAsync(cacheName, key1); - Assert.Equal(value1, getResponse.ByteArray); + var goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(value1, goodGetResponse.ByteArray); getResponse = await client.GetAsync(cacheName, key2); - Assert.Equal(value2, getResponse.ByteArray); + goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(value2, goodGetResponse.ByteArray); } [Fact] @@ -239,10 +263,12 @@ public async Task SetBatchAsync_KeysAreString_HappyPath() await client.SetBatchAsync(cacheName, dictionary); var getResponse = await client.GetAsync(cacheName, key1); - Assert.Equal(value1, getResponse.String()); + var goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(value1, goodGetResponse.String()); getResponse = await client.GetAsync(cacheName, key2); - Assert.Equal(value2, getResponse.String()); + goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(value2, goodGetResponse.String()); } [Fact] @@ -253,7 +279,8 @@ public async Task GetAsync_ExpiredTtl_HappyPath() await client.SetAsync(cacheName, key, value, 1); await Task.Delay(3000); CacheGetResponse result = await client.GetAsync(cacheName, key); - Assert.Equal(CacheGetStatus.MISS, result.Status); + var goodResult = (CacheGetResponse.Success)result; + Assert.Equal(CacheGetStatus.MISS, goodResult.Status); } [Theory] @@ -272,14 +299,16 @@ public async Task DeleteAsync_KeyIsByteArray_HappyPath() byte[] value = new byte[] { 0x05, 0x06, 0x07, 0x08 }; await client.SetAsync(cacheName, key, value, ttlSeconds: 60); CacheGetResponse getResponse = await client.GetAsync(cacheName, key); - Assert.Equal(CacheGetStatus.HIT, getResponse.Status); + var goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(CacheGetStatus.HIT, goodGetResponse.Status); // Delete await client.DeleteAsync(cacheName, key); // Check deleted getResponse = await client.GetAsync(cacheName, key); - Assert.Equal(CacheGetStatus.MISS, getResponse.Status); + goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(CacheGetStatus.MISS, goodGetResponse.Status); } [Theory] @@ -298,13 +327,15 @@ public async Task DeleteAsync_KeyIsString_HappyPath() string value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value, ttlSeconds: 60); CacheGetResponse getResponse = await client.GetAsync(cacheName, key); - Assert.Equal(CacheGetStatus.HIT, getResponse.Status); + var goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(CacheGetStatus.HIT, goodGetResponse.Status); // Delete await client.DeleteAsync(cacheName, key); // Check deleted getResponse = await client.GetAsync(cacheName, key); - Assert.Equal(CacheGetStatus.MISS, getResponse.Status); + goodGetResponse = (CacheGetResponse.Success)getResponse; + Assert.Equal(CacheGetStatus.MISS, goodGetResponse.Status); } } diff --git a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs index 5fd705ad..ca77a64a 100644 --- a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs +++ b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs @@ -14,16 +14,15 @@ public void CorrectResultMapping() string cacheBody = "test body"; ByteString body = ByteString.CopyFromUtf8(cacheBody); _GetResponse serverResponseHit = new _GetResponse() { CacheBody = body, Result = ECacheResult.Hit }; - CacheGetResponse responseHit = new CacheGetResponse(serverResponseHit); + CacheGetResponse.Success responseHit = new CacheGetResponse.Success(serverResponseHit); Assert.Equal(CacheGetStatus.HIT, responseHit.Status); Assert.Equal(cacheBody, responseHit.String()); _GetResponse serverResponseMiss = new _GetResponse() { Result = ECacheResult.Miss }; - CacheGetResponse responseMiss = new CacheGetResponse(serverResponseMiss); + CacheGetResponse.Success responseMiss = new CacheGetResponse.Success(serverResponseMiss); Assert.Equal(CacheGetStatus.MISS, responseMiss.Status); _GetResponse serverResponseBadRequest = new _GetResponse() { Result = ECacheResult.Invalid }; - _ = Assert.Throws(() => new CacheGetResponse(serverResponseBadRequest)); - + _ = Assert.Throws(() => new CacheGetResponse.Success(serverResponseBadRequest)); } } From a8b5f5fb30b9578f6cd88e880ae87b30a6b94e63 Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Fri, 23 Sep 2022 09:09:02 -0700 Subject: [PATCH 2/8] remove commented out code --- src/Momento.Sdk/Responses/CacheGetBatchResponse.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs index 12c44088..7bbd8150 100644 --- a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs @@ -16,7 +16,6 @@ public Success(IEnumerable responses) public IEnumerable Status { - // get => Responses.Select(response => response.Status); get { var ret = new List(); @@ -30,7 +29,6 @@ public IEnumerable Status public IEnumerable Strings() { - // return Responses.Select(response => response.String()); var ret = new List(); foreach (CacheGetResponse.Success response in Responses) { @@ -41,7 +39,6 @@ public IEnumerable Status public IEnumerable ByteArrays { - // get => Responses.Select(response => response.ByteArray); get { var ret = new List(); From 7c3aa6c34bb8cbd3c43ed1a212835273ab6a2d1f Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Fri, 23 Sep 2022 10:14:58 -0700 Subject: [PATCH 3/8] fix computation of value in CacheGetResponse --- src/Momento.Sdk/Responses/CacheGetResponse.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index 8f4647b8..d2e0016b 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -14,11 +14,10 @@ public Success(_GetResponse response) { if (response.Result is ECacheResult status) { Status = CacheGetStatusUtil.From(status); - this.value = response.CacheBody; } else { Status = (CacheGetStatus)response.Result; - this.value = (Status == CacheGetStatus.HIT) ? value : null; } + this.value = (Status == CacheGetStatus.HIT) ? response.CacheBody : null; } public byte[]? ByteArray From 462abf782fe8258570a5fecc37a34bdebd1755de Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Fri, 23 Sep 2022 10:18:25 -0700 Subject: [PATCH 4/8] fix a response I missed --- src/Momento.Sdk/Internal/ScsDataClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Momento.Sdk/Internal/ScsDataClient.cs b/src/Momento.Sdk/Internal/ScsDataClient.cs index 3c6fec0c..fcf75942 100644 --- a/src/Momento.Sdk/Internal/ScsDataClient.cs +++ b/src/Momento.Sdk/Internal/ScsDataClient.cs @@ -226,8 +226,8 @@ private async Task SendDeleteAsync(string cacheName, ByteSt } catch (Exception e) { - throw CacheExceptionMapper.Convert(e); + return new CacheDeleteResponse.Error(CacheExceptionMapper.Convert(e)); } - return new CacheDeleteResponse(); + return new CacheDeleteResponse.Success(); } } From efab84902f21460c853c65741533fcac5933c4a5 Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Fri, 23 Sep 2022 14:28:03 -0700 Subject: [PATCH 5/8] make response classes abstract --- src/Momento.Sdk/Responses/CacheGetBatchResponse.cs | 2 +- src/Momento.Sdk/Responses/CacheGetResponse.cs | 2 +- src/Momento.Sdk/Responses/CacheSetBatchResponse.cs | 2 +- src/Momento.Sdk/Responses/CacheSetResponse.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs index 7bbd8150..d78283e9 100644 --- a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs @@ -3,7 +3,7 @@ namespace Momento.Sdk.Responses; -public class CacheGetBatchResponse +public abstract class CacheGetBatchResponse { public class Success : CacheGetBatchResponse { diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index d2e0016b..114ca7a6 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -3,7 +3,7 @@ using Momento.Sdk.Exceptions; namespace Momento.Sdk.Responses; -public class CacheGetResponse +public abstract class CacheGetResponse { public class Success : CacheGetResponse { diff --git a/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs index b4484a3e..4df968a4 100644 --- a/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetBatchResponse.cs @@ -2,7 +2,7 @@ namespace Momento.Sdk.Responses; using Momento.Sdk.Exceptions; -public class CacheSetBatchResponse +public abstract class CacheSetBatchResponse { public class Success : CacheSetBatchResponse { } diff --git a/src/Momento.Sdk/Responses/CacheSetResponse.cs b/src/Momento.Sdk/Responses/CacheSetResponse.cs index 4041ca8f..9f729bb8 100644 --- a/src/Momento.Sdk/Responses/CacheSetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheSetResponse.cs @@ -2,7 +2,7 @@ using Momento.Sdk.Exceptions; -public class CacheSetResponse +public abstract class CacheSetResponse { public class Success : CacheSetResponse { } From 0aa30601938c1b4d9eb08ec47c924842e9a1249c Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Fri, 23 Sep 2022 14:59:29 -0700 Subject: [PATCH 6/8] replace success with hit/miss for get responses --- src/Momento.Sdk/Internal/ScsDataClient.cs | 6 +++- .../Responses/CacheGetBatchResponse.cs | 28 ++++++++++----- src/Momento.Sdk/Responses/CacheGetResponse.cs | 12 +++++-- .../Momento.Sdk.Tests/SimpleCacheDataTest.cs | 36 +++++++++---------- .../Responses/CacheGetResponseTest.cs | 12 +++---- 5 files changed, 59 insertions(+), 35 deletions(-) diff --git a/src/Momento.Sdk/Internal/ScsDataClient.cs b/src/Momento.Sdk/Internal/ScsDataClient.cs index fcf75942..695a1060 100644 --- a/src/Momento.Sdk/Internal/ScsDataClient.cs +++ b/src/Momento.Sdk/Internal/ScsDataClient.cs @@ -214,7 +214,11 @@ private async Task SendGetAsync(string cacheName, ByteString k { return new CacheGetResponse.Error(CacheExceptionMapper.Convert(e)); } - return new CacheGetResponse.Success(response); + + if (response.Result == ECacheResult.Miss) { + return new CacheGetResponse.Miss(); + } + return new CacheGetResponse.Hit(response); } private async Task SendDeleteAsync(string cacheName, ByteString key) diff --git a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs index d78283e9..db1d28b1 100644 --- a/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetBatchResponse.cs @@ -19,9 +19,12 @@ public IEnumerable Status get { var ret = new List(); - foreach (CacheGetResponse.Success response in Responses) - { - ret.Add(response.Status); + foreach (CacheGetResponse response in Responses) { + if (response is CacheGetResponse.Hit hitResponse) { + ret.Add(hitResponse.Status); + } else if (response is CacheGetResponse.Miss missResponse) { + ret.Add(missResponse.Status); + } } return ret; } @@ -30,9 +33,13 @@ public IEnumerable Status public IEnumerable Strings() { var ret = new List(); - foreach (CacheGetResponse.Success response in Responses) + foreach (CacheGetResponse response in Responses) { - ret.Add(response.String()); + if (response is CacheGetResponse.Hit hitResponse) { + ret.Add(hitResponse.String()); + } else if (response is CacheGetResponse.Miss missResponse) { + ret.Add(null); + } } return ret.ToArray(); } @@ -42,11 +49,16 @@ public IEnumerable ByteArrays get { var ret = new List(); - foreach (CacheGetResponse.Success response in Responses) + foreach (CacheGetResponse response in Responses) { - ret.Add(response.ByteArray); + if (response is CacheGetResponse.Hit hitResponse) + { + ret.Add(hitResponse.ByteArray); + } else if (response is CacheGetResponse.Miss missResponse) { + ret.Add(null); + } } - return ret; + return ret.ToArray(); } } } diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index 114ca7a6..14a7c81f 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -5,12 +5,12 @@ namespace Momento.Sdk.Responses; public abstract class CacheGetResponse { - public class Success : CacheGetResponse + public class Hit : CacheGetResponse { public CacheGetStatus Status { get; } protected readonly ByteString? value; - public Success(_GetResponse response) + public Hit(_GetResponse response) { if (response.Result is ECacheResult status) { Status = CacheGetStatusUtil.From(status); @@ -26,6 +26,14 @@ public byte[]? ByteArray } public string? String() => (value != null) ? value.ToStringUtf8() : null; + } + + public class Miss : CacheGetResponse { + public CacheGetStatus Status { get; } + + public Miss() { + Status = CacheGetStatus.MISS; + } } diff --git a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs index 7cc93c41..37ee3b22 100644 --- a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs +++ b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs @@ -39,7 +39,7 @@ public async Task SetAsync_KeyIsByteArrayValueIsByteArray_HappyPath() byte[] value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value); CacheGetResponse response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Success goodResponse) { + if (response is CacheGetResponse.Hit goodResponse) { byte[]? setValue = goodResponse.ByteArray; Assert.Equal(value, setValue); } @@ -48,7 +48,7 @@ public async Task SetAsync_KeyIsByteArrayValueIsByteArray_HappyPath() value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Success anotherGoodResponse) { + if (response is CacheGetResponse.Hit anotherGoodResponse) { byte[]? setValue = anotherGoodResponse.ByteArray; Assert.Equal(value, setValue); } @@ -80,7 +80,7 @@ public async Task SetAsync_KeyIsStringValueIsString_HappyPath() string value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value); CacheGetResponse response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Success goodResponse) { + if (response is CacheGetResponse.Hit goodResponse) { string? setValue = goodResponse.String(); Assert.Equal(value, setValue); } @@ -89,7 +89,7 @@ public async Task SetAsync_KeyIsStringValueIsString_HappyPath() value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Success anotherGoodResponse) { + if (response is CacheGetResponse.Hit anotherGoodResponse) { string? setValue = anotherGoodResponse.String(); Assert.Equal(value, setValue); } @@ -121,7 +121,7 @@ public async Task SetAsync_KeyIsStringValueIsByteArray_HappyPath() byte[] value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value); CacheGetResponse response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Success goodResponse) { + if (response is CacheGetResponse.Hit goodResponse) { byte[]? setValue = goodResponse.ByteArray; Assert.Equal(value, setValue); } @@ -130,7 +130,7 @@ public async Task SetAsync_KeyIsStringValueIsByteArray_HappyPath() value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); response = await client.GetAsync(cacheName, key); - var anotherGoodResponse = (CacheGetResponse.Success)response; + var anotherGoodResponse = (CacheGetResponse.Hit)response; byte[]? anotherSetValue = anotherGoodResponse.ByteArray; Assert.Equal(value, anotherSetValue); } @@ -230,11 +230,11 @@ public async Task SetBatchAsync_ItemsAreByteArray_HappyPath() await client.SetBatchAsync(cacheName, dictionary); var getResponse = await client.GetAsync(cacheName, key1); - var goodGetResponse = (CacheGetResponse.Success)getResponse; + var goodGetResponse = (CacheGetResponse.Hit)getResponse; Assert.Equal(value1, goodGetResponse.ByteArray); getResponse = await client.GetAsync(cacheName, key2); - goodGetResponse = (CacheGetResponse.Success)getResponse; + goodGetResponse = (CacheGetResponse.Hit)getResponse; Assert.Equal(value2, goodGetResponse.ByteArray); } @@ -263,11 +263,11 @@ public async Task SetBatchAsync_KeysAreString_HappyPath() await client.SetBatchAsync(cacheName, dictionary); var getResponse = await client.GetAsync(cacheName, key1); - var goodGetResponse = (CacheGetResponse.Success)getResponse; + var goodGetResponse = (CacheGetResponse.Hit)getResponse; Assert.Equal(value1, goodGetResponse.String()); getResponse = await client.GetAsync(cacheName, key2); - goodGetResponse = (CacheGetResponse.Success)getResponse; + goodGetResponse = (CacheGetResponse.Hit)getResponse; Assert.Equal(value2, goodGetResponse.String()); } @@ -279,8 +279,8 @@ public async Task GetAsync_ExpiredTtl_HappyPath() await client.SetAsync(cacheName, key, value, 1); await Task.Delay(3000); CacheGetResponse result = await client.GetAsync(cacheName, key); - var goodResult = (CacheGetResponse.Success)result; - Assert.Equal(CacheGetStatus.MISS, goodResult.Status); + var missResult = (CacheGetResponse.Miss)result; + Assert.Equal(CacheGetStatus.MISS, missResult.Status); } [Theory] @@ -299,7 +299,7 @@ public async Task DeleteAsync_KeyIsByteArray_HappyPath() byte[] value = new byte[] { 0x05, 0x06, 0x07, 0x08 }; await client.SetAsync(cacheName, key, value, ttlSeconds: 60); CacheGetResponse getResponse = await client.GetAsync(cacheName, key); - var goodGetResponse = (CacheGetResponse.Success)getResponse; + var goodGetResponse = (CacheGetResponse.Hit)getResponse; Assert.Equal(CacheGetStatus.HIT, goodGetResponse.Status); // Delete @@ -307,8 +307,8 @@ public async Task DeleteAsync_KeyIsByteArray_HappyPath() // Check deleted getResponse = await client.GetAsync(cacheName, key); - goodGetResponse = (CacheGetResponse.Success)getResponse; - Assert.Equal(CacheGetStatus.MISS, goodGetResponse.Status); + var missGetResponse = (CacheGetResponse.Miss)getResponse; + Assert.Equal(CacheGetStatus.MISS, missGetResponse.Status); } [Theory] @@ -327,7 +327,7 @@ public async Task DeleteAsync_KeyIsString_HappyPath() string value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value, ttlSeconds: 60); CacheGetResponse getResponse = await client.GetAsync(cacheName, key); - var goodGetResponse = (CacheGetResponse.Success)getResponse; + var goodGetResponse = (CacheGetResponse.Hit)getResponse; Assert.Equal(CacheGetStatus.HIT, goodGetResponse.Status); // Delete @@ -335,7 +335,7 @@ public async Task DeleteAsync_KeyIsString_HappyPath() // Check deleted getResponse = await client.GetAsync(cacheName, key); - goodGetResponse = (CacheGetResponse.Success)getResponse; - Assert.Equal(CacheGetStatus.MISS, goodGetResponse.Status); + var missGetResponse = (CacheGetResponse.Miss)getResponse; + Assert.Equal(CacheGetStatus.MISS, missGetResponse.Status); } } diff --git a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs index ca77a64a..044ebd36 100644 --- a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs +++ b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs @@ -14,15 +14,15 @@ public void CorrectResultMapping() string cacheBody = "test body"; ByteString body = ByteString.CopyFromUtf8(cacheBody); _GetResponse serverResponseHit = new _GetResponse() { CacheBody = body, Result = ECacheResult.Hit }; - CacheGetResponse.Success responseHit = new CacheGetResponse.Success(serverResponseHit); + CacheGetResponse.Hit responseHit = new CacheGetResponse.Hit(serverResponseHit); Assert.Equal(CacheGetStatus.HIT, responseHit.Status); Assert.Equal(cacheBody, responseHit.String()); - _GetResponse serverResponseMiss = new _GetResponse() { Result = ECacheResult.Miss }; - CacheGetResponse.Success responseMiss = new CacheGetResponse.Success(serverResponseMiss); - Assert.Equal(CacheGetStatus.MISS, responseMiss.Status); + // _GetResponse serverResponseMiss = new _GetResponse() { Result = ECacheResult.Miss }; + // CacheGetResponse.Miss responseMiss = new CacheGetResponse.Miss(serverResponseMiss); + // Assert.Equal(CacheGetStatus.MISS, responseMiss.Status); - _GetResponse serverResponseBadRequest = new _GetResponse() { Result = ECacheResult.Invalid }; - _ = Assert.Throws(() => new CacheGetResponse.Success(serverResponseBadRequest)); + // _GetResponse serverResponseBadRequest = new _GetResponse() { Result = ECacheResult.Invalid }; + // _ = Assert.Throws(() => new CacheGetResponse.Success(serverResponseBadRequest)); } } From bee2e90ebd98fa7aeb4e7c268b8f1ee83d01b7bb Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Fri, 23 Sep 2022 15:17:43 -0700 Subject: [PATCH 7/8] testing fixes --- src/Momento.Sdk/Internal/ScsDataClient.cs | 7 ++++ .../Momento.Sdk.Tests/SimpleCacheDataTest.cs | 40 ++++++++----------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/Momento.Sdk/Internal/ScsDataClient.cs b/src/Momento.Sdk/Internal/ScsDataClient.cs index 695a1060..7cd6b466 100644 --- a/src/Momento.Sdk/Internal/ScsDataClient.cs +++ b/src/Momento.Sdk/Internal/ScsDataClient.cs @@ -134,6 +134,13 @@ public async Task GetBatchAsync(string cacheName, IEnumer ); } + // preserve old behavior of failing on first error + foreach (CacheGetResponse response in continuation.Result) { + if (response is CacheGetResponse.Error errorResponse) { + return new CacheGetBatchResponse.Error(errorResponse.Exception); + } + } + // Package results return new CacheGetBatchResponse.Success(continuation.Result); } diff --git a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs index 37ee3b22..f6c0fab9 100644 --- a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs +++ b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs @@ -39,19 +39,17 @@ public async Task SetAsync_KeyIsByteArrayValueIsByteArray_HappyPath() byte[] value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value); CacheGetResponse response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Hit goodResponse) { - byte[]? setValue = goodResponse.ByteArray; - Assert.Equal(value, setValue); - } + var goodResponse = (CacheGetResponse.Hit)response; + byte[]? setValue = goodResponse.ByteArray; + Assert.Equal(value, setValue); key = Utils.NewGuidByteArray(); value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Hit anotherGoodResponse) { - byte[]? setValue = anotherGoodResponse.ByteArray; - Assert.Equal(value, setValue); - } + goodResponse = (CacheGetResponse.Hit)response; + setValue = goodResponse.ByteArray; + Assert.Equal(value, setValue); } [Theory] @@ -80,19 +78,17 @@ public async Task SetAsync_KeyIsStringValueIsString_HappyPath() string value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value); CacheGetResponse response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Hit goodResponse) { - string? setValue = goodResponse.String(); - Assert.Equal(value, setValue); - } + var goodResponse = (CacheGetResponse.Hit)response; + string? setValue = goodResponse.String(); + Assert.Equal(value, setValue); key = Utils.NewGuidString(); value = Utils.NewGuidString(); await client.SetAsync(cacheName, key, value, ttlSeconds: 15); response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Hit anotherGoodResponse) { - string? setValue = anotherGoodResponse.String(); - Assert.Equal(value, setValue); - } + goodResponse = (CacheGetResponse.Hit)response; + setValue = goodResponse.String(); + Assert.Equal(value, setValue); } [Theory] @@ -121,10 +117,9 @@ public async Task SetAsync_KeyIsStringValueIsByteArray_HappyPath() byte[] value = Utils.NewGuidByteArray(); await client.SetAsync(cacheName, key, value); CacheGetResponse response = await client.GetAsync(cacheName, key); - if (response is CacheGetResponse.Hit goodResponse) { - byte[]? setValue = goodResponse.ByteArray; - Assert.Equal(value, setValue); - } + var goodResponse = (CacheGetResponse.Hit)response; + byte[]? setValue = goodResponse.ByteArray; + Assert.Equal(value, setValue); key = Utils.NewGuidString(); value = Utils.NewGuidByteArray(); @@ -200,9 +195,8 @@ public async Task GetBatchAsync_Failure() using SimpleCacheClient simpleCacheClient = new SimpleCacheClient(Configurations.Laptop.Latest, authToken, DefaultTtlSeconds, 1); List keys = new() { Utils.NewGuidString(), Utils.NewGuidString(), Utils.NewGuidString(), Utils.NewGuidString() }; CacheGetBatchResponse response = await simpleCacheClient.GetBatchAsync(cacheName, keys); - if (response is CacheGetBatchResponse.Error badResponse) { - Assert.Equal(MomentoErrorCode.TIMEOUT_ERROR, badResponse.ErrorCode); - } + var badResponse = (CacheGetBatchResponse.Error)response; + Assert.Equal(MomentoErrorCode.TIMEOUT_ERROR, badResponse.ErrorCode); } [Fact] From 5b620a0a83ee8e6d48aaf5d2058984ed7a7c4d6e Mon Sep 17 00:00:00 2001 From: Pete Gautier Date: Mon, 26 Sep 2022 10:51:04 -0700 Subject: [PATCH 8/8] make value not nullable --- src/Momento.Sdk/Responses/CacheGetResponse.cs | 24 +++++++------------ .../Responses/CacheGetResponseTest.cs | 7 ------ 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index 14a7c81f..dda05e54 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -7,34 +7,28 @@ public abstract class CacheGetResponse { public class Hit : CacheGetResponse { - public CacheGetStatus Status { get; } - protected readonly ByteString? value; + public CacheGetStatus Status { get => CacheGetStatus.HIT; } + protected readonly ByteString value; public Hit(_GetResponse response) { - if (response.Result is ECacheResult status) { - Status = CacheGetStatusUtil.From(status); - } else { - Status = (CacheGetStatus)response.Result; - } - this.value = (Status == CacheGetStatus.HIT) ? response.CacheBody : null; + this.value = response.CacheBody; } - public byte[]? ByteArray + public byte[] ByteArray { - get => value != null ? value.ToByteArray() : null; + get => value.ToByteArray(); } - public string? String() => (value != null) ? value.ToStringUtf8() : null; + public string String() => value.ToStringUtf8(); } public class Miss : CacheGetResponse { - public CacheGetStatus Status { get; } - - public Miss() { - Status = CacheGetStatus.MISS; + public CacheGetStatus Status { + get => CacheGetStatus.MISS; } + public Miss() { } } public class Error : CacheGetResponse diff --git a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs index 044ebd36..0c8d21ad 100644 --- a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs +++ b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs @@ -17,12 +17,5 @@ public void CorrectResultMapping() CacheGetResponse.Hit responseHit = new CacheGetResponse.Hit(serverResponseHit); Assert.Equal(CacheGetStatus.HIT, responseHit.Status); Assert.Equal(cacheBody, responseHit.String()); - - // _GetResponse serverResponseMiss = new _GetResponse() { Result = ECacheResult.Miss }; - // CacheGetResponse.Miss responseMiss = new CacheGetResponse.Miss(serverResponseMiss); - // Assert.Equal(CacheGetStatus.MISS, responseMiss.Status); - - // _GetResponse serverResponseBadRequest = new _GetResponse() { Result = ECacheResult.Invalid }; - // _ = Assert.Throws(() => new CacheGetResponse.Success(serverResponseBadRequest)); } }