Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions StackExchange.Redis.Tests/Values.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Linq;
using System.Text;
using Xunit;
using Xunit.Abstractions;

namespace StackExchange.Redis.Tests
{
public class Values : TestBase
{
public Values(ITestOutputHelper output) : base (output) { }

[Fact]
public void NullValueChecks()
{
RedisValue four = 4;
Assert.False(four.IsNull);
Assert.True(four.IsInteger);
Assert.True(four.HasValue);
Assert.False(four.IsNullOrEmpty);

RedisValue n = default(RedisValue);
Assert.True(n.IsNull);
Assert.False(n.IsInteger);
Assert.False(n.HasValue);
Assert.True(n.IsNullOrEmpty);

RedisValue emptyArr = new byte[0];
Assert.False(emptyArr.IsNull);
Assert.False(emptyArr.IsInteger);
Assert.False(emptyArr.HasValue);
Assert.True(emptyArr.IsNullOrEmpty);
}
}
}
4 changes: 2 additions & 2 deletions StackExchange.Redis/StackExchange/Redis/RedisValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ private RedisValue(long valueInt64, byte[] valueBlob)
public bool IsNullOrEmpty => valueBlob == null || (valueBlob.Length == 0 && !(valueBlob == IntegerSentinel));

/// <summary>
/// Indicates whether the value is greater than zero-length
/// Indicates whether the value is greater than zero-length or has an integer value
/// </summary>
public bool HasValue => valueBlob?.Length > 0;
public bool HasValue => !IsNullOrEmpty;

/// <summary>
/// Indicates whether two RedisValue values are equivalent
Expand Down