Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add More Coverage #54

Merged
merged 22 commits into from
Jan 4, 2023
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,7 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
.idea
.idea
tests/NRedisStack.Tests/lcov.net7.0.info
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

**/*.info

tests/NRedisStack.Tests/lcov.net6.0.info
tests/NRedisStack.Tests/lcov.info
2 changes: 2 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{
"dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov /p:CoverletOutput=./lcov.info",
"dotnet-test-explorer.testProjectPath": "**/*NRedisStack.Tests.csproj"
}
18 changes: 18 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
"${workspaceFolder}/tests/NRedisStack.Tests/NRedisStack.Tests.csproj"
],
"problemMatcher": "$msCompile"
},
{
"label": "test",
"dependsOn": [],
"command": "dotnet",
"type": "process",
"args": [
"test",
"${workspaceFolder}/tests/NRedisStack.Tests/NRedisStack.Tests.csproj",
"/p:CollectCoverage=true",
"/p:CoverletOutputFormat=lcov",
"/p:CoverletOutput=./lcov.info"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
8 changes: 4 additions & 4 deletions src/NRedisStack/CuckooFilter/DataTypes/CuckooInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ public class CuckooInformation
{
public long Size { get; private set; }
public long NumberOfBuckets { get; private set; }
public long NumberOfFilter { get; private set; }
public long NumberOfFilters { get; private set; }
public long NumberOfItemsInserted { get; private set; }
public long NumberOfItemsDeleted { get; private set; }
public long BucketSize { get; private set; }
public long ExpansionRate { get; private set; }
public long MaxIteration { get; private set; }
public long MaxIterations { get; private set; }

internal CuckooInformation(long size, long numberOfBuckets, long numberOfFilter,
long numberOfItemsInserted, long numberOfItemsDeleted,
long bucketSize, long expansionRate, long maxIteration)
{
Size = size;
NumberOfBuckets = numberOfBuckets;
NumberOfFilter = numberOfFilter;
NumberOfFilters = numberOfFilter;
NumberOfItemsInserted = numberOfItemsInserted;
NumberOfItemsDeleted = numberOfItemsDeleted;
BucketSize = bucketSize;
ExpansionRate = expansionRate;
MaxIteration = maxIteration;
MaxIterations = maxIteration;
}
}
}
1 change: 1 addition & 0 deletions src/NRedisStack/Graph/DataTypes/Edge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class Edge : GraphEntity
/// <value></value>
public long Destination { get; set; }

// TODO: check if this is needed:
/// <summary>
/// Overriden from the base `Equals` implementation. In addition to the expected behavior of checking
/// reference equality, we'll also fall back and check to see if the: Source, Destination, and RelationshipType
Expand Down
1 change: 1 addition & 0 deletions src/NRedisStack/Graph/DataTypes/GraphEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public abstract class GraphEntity

public IDictionary<string, object> PropertyMap = new Dictionary<string, object>();

// TODO: check if this is needed:
/// <summary>
/// Overriden Equals that considers the equality of the entity ID as well as the equality of the
/// properties that each entity has.
Expand Down
1 change: 1 addition & 0 deletions src/NRedisStack/Graph/DataTypes/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public Node()
Labels = new List<string>();
}

// TODO: check if this is needed:
/// <summary>
/// Overriden member that checks to see if the names of the labels of a node are equal
/// (in addition to base `Equals` functionality).
Expand Down
8 changes: 2 additions & 6 deletions src/NRedisStack/Graph/DataTypes/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ public Path(IList<Node> nodes, IList<Edge> edges)
Edges = new ReadOnlyCollection<Edge>(edges);
}


/// <summary>
/// How many edges exist on this path.
/// </summary>
public int Length => Edges.Count;

// TODO: check if this is needed:
/// <summary>
/// Overriden `Equals` method that will consider the equality of the Nodes and Edges between two paths.
/// </summary>
Expand Down Expand Up @@ -73,6 +68,7 @@ public override int GetHashCode()
}
}

// TODO: check if this is needed:
/// <summary>
/// Overridden `ToString` method that will emit a string based on the string values of the nodes and edges
/// on the path.
Expand Down
16 changes: 0 additions & 16 deletions src/NRedisStack/Graph/GraphCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ public static class GraphCommandBuilder
{
internal static readonly object CompactQueryFlag = "--COMPACT";

/// <inheritdoc/>
public static SerializedCommand Query(string graphName, string query, IDictionary<string, object> parameters, long? timeout = null)
{
var preparedQuery = PrepareQuery(query, parameters);

return Query(graphName, preparedQuery, timeout);
}

/// <inheritdoc/>
public static SerializedCommand Query(string graphName, string query, long? timeout = null)
{
Expand All @@ -25,14 +17,6 @@ public static SerializedCommand Query(string graphName, string query, long? time
return new SerializedCommand(GRAPH.QUERY, args);
}

/// <inheritdoc/>
public static SerializedCommand RO_Query(string graphName, string query, IDictionary<string, object> parameters, long? timeout = null)
{
var preparedQuery = PrepareQuery(query, parameters);

return RO_Query(graphName, preparedQuery, timeout);
}

/// <inheritdoc/>
public static SerializedCommand RO_Query(string graphName, string query, long? timeout = null)
{
Expand Down
10 changes: 0 additions & 10 deletions src/NRedisStack/Graph/GraphCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ public GraphCommands(IDatabase db)

private readonly IDictionary<string, GraphCache> _graphCaches = new Dictionary<string, GraphCache>();

private GraphCache GetGraphCache(string graphName)
{
if (!_graphCaches.ContainsKey(graphName))
{
_graphCaches.Add(graphName, new GraphCache(graphName, this));
}

return _graphCaches[graphName];
}

/// <inheritdoc/>
public ResultSet Query(string graphName, string query, IDictionary<string, object> parameters, long? timeout = null)
{
Expand Down
1 change: 1 addition & 0 deletions src/NRedisStack/Graph/Header.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ internal Header(RedisResult result)
}
}

// TODO: check if this is needed:
public override bool Equals(object? obj)
{
if (obj == null) return this == null;
Expand Down
1 change: 1 addition & 0 deletions src/NRedisStack/Graph/Point.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public Point(List<double> values)
this.longitude = values[1];
}

// TODO: check if this is needed:
public override bool Equals(object? obj)
{
if (obj == null) return this == null;
Expand Down
1 change: 1 addition & 0 deletions src/NRedisStack/Graph/Record.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal Record(List<string> header, List<object> values)
/// </summary>
public int Size => Header.Count;

// TODO: check if this is needed:
public override bool Equals(object? obj)
{
if (obj == null) return this == null;
Expand Down
10 changes: 0 additions & 10 deletions src/NRedisStack/Json/IJsonCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,16 +394,6 @@ public interface IJsonCommands
/// <remarks><seealso href="https://redis.io/commands/json.get"/></remarks>
Task<T?> GetAsync<T>(RedisKey key, string path = "$");

/// <summary>
/// retrieves a group of items stored in redis, appropriate if the path will resolve to multiple records.
/// </summary>
/// <param name="key">The key to pull from.</param>
/// <param name="path">The path to pull.</param>
/// <typeparam name="T">The type.</typeparam>
/// <returns>An enumerable of the requested tyep</returns>
/// <remarks><seealso href="https://redis.io/commands/json.get"/></remarks>
Task<IEnumerable<T?>> GetEnumerableAsync<T>(RedisKey key, string path = "$");

/// <summary>
/// Gets the provided path from multiple keys
/// </summary>
Expand Down
23 changes: 5 additions & 18 deletions src/NRedisStack/Json/JsonCommandBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ public static SerializedCommand Resp(RedisKey key, string? path = null)
return new SerializedCommand(JSON.RESP, key, path);
}

public static SerializedCommand Set(RedisKey key, RedisValue path, object obj, When when = When.Always)
{
string json = JsonSerializer.Serialize(obj);
return Set(key, path, json, when);
}

public static SerializedCommand Set(RedisKey key, RedisValue path, RedisValue json, When when = When.Always)
{
return when switch
Expand Down Expand Up @@ -137,8 +131,6 @@ public static SerializedCommand Del(RedisKey key, string? path = null)
return new SerializedCommand(JSON.DEL, args);
}

public static SerializedCommand Forget(RedisKey key, string? path = null) => Del(key, path);

public static SerializedCommand Get(RedisKey key, RedisValue? indent = null, RedisValue? newLine = null, RedisValue? space = null, RedisValue? path = null)
{
List<object> args = new List<object>() { key };
Expand Down Expand Up @@ -173,11 +165,6 @@ public static SerializedCommand Get(RedisKey key, string[] paths, RedisValue? in
{
List<object> args = new List<object>() { key };

foreach (var path in paths)
{
args.Add(path);
}

if (indent != null)
{
args.Add(JsonArgs.INDENT);
Expand All @@ -196,6 +183,11 @@ public static SerializedCommand Get(RedisKey key, string[] paths, RedisValue? in
args.Add(space);
}

foreach (var path in paths)
{
args.Add(path);
}

return new SerializedCommand(JSON.GET, args);
}

Expand All @@ -205,11 +197,6 @@ public static SerializedCommand Get<T>(RedisKey key, string path = "$")

}

public static SerializedCommand GetEnumerable<T>(RedisKey key, string path = "$")
{
return new SerializedCommand(JSON.GET, key, path);
}

public static SerializedCommand MGet(RedisKey[] keys, string path)
{
var args = new List<object>();
Expand Down
5 changes: 0 additions & 5 deletions src/NRedisStack/Json/JsonCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,6 @@ public async Task<RedisResult> GetAsync(RedisKey key, string[] paths, RedisValue
return default;
}

public Task<IEnumerable<T?>> GetEnumerableAsync<T>(RedisKey key, string path = "$") // TODO: why is this here?
{
throw new NotImplementedException();
}

public async Task<RedisResult[]> MGetAsync(RedisKey[] keys, string path)
{
return (await _db.ExecuteAsync(JsonCommandBuilder.MGet(keys, path))).ToArray();
Expand Down
Loading