Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 5 additions & 2 deletions src/OpenFeature/Model/ImmutableMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public sealed class ImmutableMetadata
/// </value>
public bool IsEmpty => this._metadata.Count == 0;

/// <summary>
/// Gets the number of elements in this collection.
/// </summary>
public int Count => this._metadata.Count;

/// <summary>
/// Constructor for the <see cref="ImmutableMetadata"/> class.
/// </summary>
Expand Down Expand Up @@ -104,6 +109,4 @@ public ImmutableMetadata(Dictionary<string, object> metadata)

return value is T tValue ? tValue : null;
}

internal int Count => this._metadata.Count;
}
22 changes: 21 additions & 1 deletion test/OpenFeature.Tests/ImmutableMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public void IsEmpty_ShouldReturnFalse()
{
// Arrange
var metadata = new Dictionary<string, object>
{
{
{
"wrongKey", new object()
},
Expand All @@ -359,4 +359,24 @@ public void IsEmpty_ShouldReturnFalse()
// Assert
Assert.False(result);
}

[Theory]
[InlineData(0)]
[InlineData(1)]
[InlineData(1000)]
public void Count_ShouldReturnCorrectNumber(int numberOfItems)
{
var metadata = new Dictionary<string, object>();
for (int i = 0; i < numberOfItems; i++)
{
metadata.Add($"key{i}", $"value{i}");
}
Comment thread
kylejuliandev marked this conversation as resolved.
Outdated
var flagMetadata = new ImmutableMetadata(metadata);

// Act
var count = flagMetadata.Count;

// Assert
Assert.Equal(numberOfItems, count);
}
}
Loading