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
8 changes: 8 additions & 0 deletions src/OpenFeature/Model/ImmutableMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ public sealed class ImmutableMetadata
{
private readonly ImmutableDictionary<string, object> _metadata;

/// <summary>
/// Gets a value indicating whether this instance is empty.
/// </summary>
/// <value>
/// <c>true</c> if this instance is empty; otherwise, <c>false</c>.
/// </value>
public bool IsEmpty => this._metadata.Count == 0;

/// <summary>
/// Constructor for the <see cref="ImmutableMetadata"/> class.
/// </summary>
Expand Down
44 changes: 44 additions & 0 deletions test/OpenFeature.Tests/ImmutableMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,48 @@ public void Count_ShouldReturnCountOfMetadata()
// Assert
Assert.Equal(metadata.Count, result);
}

[Fact]
public void IsEmpty_ShouldReturnTrue()
{
// Arrange
var flagMetadata = new ImmutableMetadata();

// Act
var result = flagMetadata.IsEmpty;

// Assert
Assert.True(result);
}

[Fact]
public void IsEmpty_ShouldReturnFalse()
{
// Arrange
var metadata = new Dictionary<string, object>
{
{
"wrongKey", new object()
},
{
"stringKey", "11"
},
{
"doubleKey", 1.2
},
{
"intKey", 1
},
{
"boolKey", true
}
};
var flagMetadata = new ImmutableMetadata(metadata);

// Act
var result = flagMetadata.IsEmpty;

// Assert
Assert.False(result);
}
}
Loading