Skip to content

Commit

Permalink
Merge pull request #451 from momentohq/feat/remove-listlength
Browse files Browse the repository at this point in the history
  • Loading branch information
rishtigupta authored Jun 8, 2023
2 parents b5bbb03 + 7c57d83 commit d1fd4da
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
9 changes: 1 addition & 8 deletions src/Momento.Sdk/Responses/CacheListFetchResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ public class Hit : CacheListFetchResponse
protected readonly Lazy<IList<string>> _stringList;
#pragma warning restore 1591

/// <summary>
/// The length of the list.
/// </summary>
public int ListLength { get; private set; }

/// <summary>
///
/// </summary>
Expand All @@ -71,8 +66,6 @@ public Hit(_ListFetchResponse response)
{
return new List<string>(values.Select(v => v.ToStringUtf8()));
});

ListLength = values.Count;
}

/// <summary>
Expand All @@ -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()}]";
}
}

Expand Down
17 changes: 1 addition & 16 deletions tests/Integration/Momento.Sdk.Tests/ListTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -1230,7 +1215,7 @@ public async Task CacheListFetchResponse_ToString_HappyPath()

Assert.True(fetchResponse is CacheListFetchResponse.Hit, $"Unexpected response: {fetchResponse}");
var hitResponse = (CacheListFetchResponse.Hit)fetchResponse;
Assert.Equal("Momento.Sdk.Responses.CacheListFetchResponse+Hit: ValueListString: [\"a\", \"b\"] ValueListByteArray: [\"61\", \"62\"] ListLength: 2", hitResponse.ToString());
Assert.Equal("Momento.Sdk.Responses.CacheListFetchResponse+Hit: ValueListString: [\"a\", \"b\"] ValueListByteArray: [\"61\", \"62\"]", hitResponse.ToString());
}

[Theory]
Expand Down

0 comments on commit d1fd4da

Please sign in to comment.