From bdd59d2f4e748462174de7faa2099e3b70f51f13 Mon Sep 17 00:00:00 2001 From: rishtigupta Date: Thu, 8 Jun 2023 10:49:19 -0700 Subject: [PATCH] feat: remove list length from listFetch api --- .../Responses/CacheListFetchResponse.cs | 9 +-------- tests/Integration/Momento.Sdk.Tests/ListTest.cs | 15 --------------- 2 files changed, 1 insertion(+), 23 deletions(-) diff --git a/src/Momento.Sdk/Responses/CacheListFetchResponse.cs b/src/Momento.Sdk/Responses/CacheListFetchResponse.cs index fd815af4..a7699485 100644 --- a/src/Momento.Sdk/Responses/CacheListFetchResponse.cs +++ b/src/Momento.Sdk/Responses/CacheListFetchResponse.cs @@ -50,11 +50,6 @@ public class Hit : CacheListFetchResponse protected readonly Lazy> _stringList; #pragma warning restore 1591 - /// - /// The length of the list. - /// - public int ListLength { get; private set; } - /// /// /// @@ -71,8 +66,6 @@ public Hit(_ListFetchResponse response) { return new List(values.Select(v => v.ToStringUtf8())); }); - - ListLength = values.Count; } /// @@ -90,7 +83,7 @@ public override string ToString() { var stringRepresentation = String.Join(", ", ValueListString.Select(value => $"\"{value}\"")); var byteArrayRepresentation = String.Join(", ", ValueListByteArray.Select(value => $"\"{value.ToPrettyHexString()}\"")); - return $"{base.ToString()}: ValueListString: [{stringRepresentation.Truncate()}] ValueListByteArray: [{byteArrayRepresentation.Truncate()}] ListLength: {ListLength}"; + return $"{base.ToString()}: ValueListString: [{stringRepresentation.Truncate()}] ValueListByteArray: [{byteArrayRepresentation.Truncate()}]"; } } diff --git a/tests/Integration/Momento.Sdk.Tests/ListTest.cs b/tests/Integration/Momento.Sdk.Tests/ListTest.cs index d719a6df..926eb0a9 100644 --- a/tests/Integration/Momento.Sdk.Tests/ListTest.cs +++ b/tests/Integration/Momento.Sdk.Tests/ListTest.cs @@ -66,7 +66,6 @@ public async Task ListFetchAsync_WithPositiveStartEndIndcies_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}"); var hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value2, value3 }, hitResponse.ValueListString); - Assert.Equal(2, hitResponse.ListLength); } [Fact] @@ -85,7 +84,6 @@ public async Task ListFetchAsync_WithNegativeStartEndIndcies_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}"); var hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value3 }, hitResponse.ValueListString); - Assert.Equal(1, hitResponse.ListLength); } [Fact] @@ -105,14 +103,12 @@ public async Task ListFetchAsync_WithNullStartIndex_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}"); var hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value1 }, hitResponse.ValueListString); - Assert.Equal(1, hitResponse.ListLength); // valid case for null startIndex and negative endIndex fetchResponse = await client.ListFetchAsync(cacheName, listName, null, -3); Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}"); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value1 }, hitResponse.ValueListString); - Assert.Equal(1, hitResponse.ListLength); } [Fact] @@ -132,14 +128,12 @@ public async Task ListFetchAsync_WithNullEndIndex_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}"); var hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value2, value3, value4 }, hitResponse.ValueListString); - Assert.Equal(3, hitResponse.ListLength); // valid case for a positive startIndex and null endIndex fetchResponse = await client.ListFetchAsync(cacheName, listName, 2, null); Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}"); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value3, value4 }, hitResponse.ValueListString); - Assert.Equal(2, hitResponse.ListLength); } [Fact] @@ -188,7 +182,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); var hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value2, value3, value4 }, hitResponse.ValueListString); - Assert.Equal(3, hitResponse.ListLength); await resetList(); retainResponse = await client.ListRetainAsync(cacheName, listName, 2, -1); @@ -197,7 +190,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value3, value4, value5 }, hitResponse.ValueListString); - Assert.Equal(3, hitResponse.ListLength); await resetList(); retainResponse = await client.ListRetainAsync(cacheName, listName, -4, -1); @@ -206,7 +198,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value3, value4, value5 }, hitResponse.ValueListString); - Assert.Equal(3, hitResponse.ListLength); await resetList(); // valid case for a negative startIndex and null endIndex @@ -216,7 +207,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value4, value5, value6 }, hitResponse.ValueListString); - Assert.Equal(3, hitResponse.ListLength); await resetList(); // valid case for a positive startIndex and null endIndex @@ -226,7 +216,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value3, value4, value5, value6 }, hitResponse.ValueListString); - Assert.Equal(4, hitResponse.ListLength); await resetList(); // valid case for null startIndex and positive endIndex @@ -236,7 +225,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value1 }, hitResponse.ValueListString); - Assert.Equal(1, hitResponse.ListLength); await resetList(); // valid case for null startIndex and negative endIndex @@ -246,7 +234,6 @@ public async Task ListRetainAsync_HappyPath() Assert.True(fetchResponse is CacheListFetchResponse.Hit); hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(new string[] { value1, value2, value3 }, hitResponse.ValueListString); - Assert.Equal(3, hitResponse.ListLength); } [Fact] @@ -1197,7 +1184,6 @@ public async Task ListFetchAsync_HasContentString_HappyPath() var hitResponse = (CacheListFetchResponse.Hit)fetchResponse; Assert.Equal(hitResponse.ValueListString, contentList); - Assert.Equal(hitResponse.ListLength, contentList.Count); } [Fact] @@ -1217,7 +1203,6 @@ public async Task ListFetchAsync_HasContentByteArray_HappyPath() Assert.Contains(field1, hitResponse.ValueListByteArray!); Assert.Contains(field2, hitResponse.ValueListByteArray!); - Assert.Equal(hitResponse.ListLength, contentList.Count); } [Fact]