diff --git a/README.template.md b/README.template.md index e409df4f..d18be54e 100644 --- a/README.template.md +++ b/README.template.md @@ -45,7 +45,7 @@ The preferred way of interpreting the return values from the Momento .NET method CacheGetResponse getResponse = await client.GetAsync(CACHE_NAME, KEY); if (getResponse is CacheGetResponse.Hit hitResponse) { - Console.WriteLine($"\nLookedup value: {hitResponse.String()}, Stored value: {VALUE}"); + Console.WriteLine($"\nLooked up value: {hitResponse.ValueString}, Stored value: {VALUE}"); } else { // you can handle other cases via pattern matching in `else if` blocks, or a default case // via the `else` block. For each return value your IDE should be able to give you code diff --git a/src/Momento.Sdk/ISimpleCacheClient.cs b/src/Momento.Sdk/ISimpleCacheClient.cs index 6840943b..b27b8f98 100644 --- a/src/Momento.Sdk/ISimpleCacheClient.cs +++ b/src/Momento.Sdk/ISimpleCacheClient.cs @@ -125,7 +125,7 @@ public interface ISimpleCacheClient : IDisposable /// /// if (response is CacheGetResponse.Hit hitResponse) /// { - /// return hitResponse.StringValue; + /// return hitResponse.ValueString; /// } else if (response is CacheGetResponse.Error errorResponse) /// { /// // handle error as appropriate diff --git a/src/Momento.Sdk/Responses/CacheGetResponse.cs b/src/Momento.Sdk/Responses/CacheGetResponse.cs index e83ddd9f..1f7c5f44 100644 --- a/src/Momento.Sdk/Responses/CacheGetResponse.cs +++ b/src/Momento.Sdk/Responses/CacheGetResponse.cs @@ -17,7 +17,7 @@ namespace Momento.Sdk.Responses; /// /// if (response is CacheGetResponse.Hit hitResponse) /// { -/// return hitResponse.StringValue; +/// return hitResponse.ValueString; /// } else if (response is CacheGetResponse.Error errorResponse) /// { /// // handle error as appropriate @@ -41,7 +41,7 @@ public Hit(_GetResponse response) /// /// Value from the cache as a byte array. /// - public byte[] ByteArrayValue + public byte[] ValueByteArray { get => value.ToByteArray(); } @@ -49,14 +49,14 @@ public byte[] ByteArrayValue /// /// Value from the cache as a string. /// - public string StringValue + public string ValueString { get => value.ToStringUtf8(); } public override string ToString() { - return $"{base.ToString()}: {this.StringValue}"; + return $"{base.ToString()}: {this.ValueString}"; } } diff --git a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs index e79973db..93ec5a47 100644 --- a/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs +++ b/tests/Integration/Momento.Sdk.Tests/SimpleCacheDataTest.cs @@ -46,7 +46,7 @@ public async Task SetAsync_KeyIsByteArrayValueIsByteArray_HappyPath() CacheGetResponse response = await client.GetAsync(cacheName, key); Assert.True(response is CacheGetResponse.Hit); var goodResponse = (CacheGetResponse.Hit)response; - byte[]? setValue = goodResponse.ByteArrayValue; + byte[] setValue = goodResponse.ValueByteArray; Assert.Equal(value, setValue); key = Utils.NewGuidByteArray(); @@ -55,7 +55,7 @@ public async Task SetAsync_KeyIsByteArrayValueIsByteArray_HappyPath() response = await client.GetAsync(cacheName, key); Assert.True(response is CacheGetResponse.Hit); goodResponse = (CacheGetResponse.Hit)response; - setValue = goodResponse.ByteArrayValue; + setValue = goodResponse.ValueByteArray; Assert.Equal(value, setValue); } @@ -97,7 +97,7 @@ public async Task SetAsync_KeyIsStringValueIsString_HappyPath() CacheGetResponse response = await client.GetAsync(cacheName, key); Assert.True(response is CacheGetResponse.Hit); var goodResponse = (CacheGetResponse.Hit)response; - string? setValue = goodResponse.StringValue; + string setValue = goodResponse.ValueString; Assert.Equal(value, setValue); // Set with TTL @@ -109,7 +109,7 @@ public async Task SetAsync_KeyIsStringValueIsString_HappyPath() response = await client.GetAsync(cacheName, key); Assert.True(response is CacheGetResponse.Hit); goodResponse = (CacheGetResponse.Hit)response; - setValue = goodResponse.StringValue; + setValue = goodResponse.ValueString; Assert.Equal(value, setValue); } @@ -150,7 +150,7 @@ public async Task SetAsync_KeyIsStringValueIsByteArray_HappyPath() CacheGetResponse response = await client.GetAsync(cacheName, key); var goodResponse = (CacheGetResponse.Hit)response; - byte[]? setValue = goodResponse.ByteArrayValue; + byte[] setValue = goodResponse.ValueByteArray; Assert.Equal(value, setValue); // Set with TTL @@ -161,7 +161,7 @@ public async Task SetAsync_KeyIsStringValueIsByteArray_HappyPath() response = await client.GetAsync(cacheName, key); var anotherGoodResponse = (CacheGetResponse.Hit)response; - byte[]? anotherSetValue = anotherGoodResponse.ByteArrayValue; + byte[] anotherSetValue = anotherGoodResponse.ValueByteArray; Assert.Equal(value, anotherSetValue); } diff --git a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs index 631fb440..c73d804c 100644 --- a/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs +++ b/tests/Unit/Momento.Sdk.Tests/Responses/CacheGetResponseTest.cs @@ -15,6 +15,6 @@ public void CorrectResultMapping() ByteString body = ByteString.CopyFromUtf8(cacheBody); _GetResponse serverResponseHit = new _GetResponse() { CacheBody = body, Result = ECacheResult.Hit }; CacheGetResponse.Hit responseHit = new CacheGetResponse.Hit(serverResponseHit); - Assert.Equal(cacheBody, responseHit.StringValue); + Assert.Equal(cacheBody, responseHit.ValueString); } }