Skip to content

Commit

Permalink
Fixing unit tests.
Browse files Browse the repository at this point in the history
Signed-off-by: André Silva <[email protected]>
  • Loading branch information
askpt committed Feb 2, 2024
1 parent c14361f commit 2b2a64f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions test/OpenFeature.Tests/FlagMetadataTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ public void GetBool_Should_Throw_Value_Is_Invalid()
var flagMetadata = new FlagMetadata(metadata);

// Act
var exception = Assert.Throws<InvalidCastException>(() => flagMetadata.GetBool("wrongKey"));
var result = flagMetadata.GetBool("wrongKey");

// Assert
Assert.NotNull(exception);
Assert.Equal("Cannot cast System.String to System.Boolean", exception.Message);
Assert.Null(result);
}

[Fact]
Expand Down Expand Up @@ -121,11 +120,10 @@ public void GetInt_Should_Throw_Value_Is_Invalid()
var flagMetadata = new FlagMetadata(metadata);

// Act
var exception = Assert.Throws<InvalidCastException>(() => flagMetadata.GetInt("wrongKey"));
var result = flagMetadata.GetInt("wrongKey");

// Assert
Assert.NotNull(exception);
Assert.Equal("Cannot cast System.String to System.Int32", exception.Message);
Assert.Null(result);
}

[Fact]
Expand Down Expand Up @@ -181,11 +179,10 @@ public void GetDouble_Should_Throw_Value_Is_Invalid()
var flagMetadata = new FlagMetadata(metadata);

// Act
var exception = Assert.Throws<InvalidCastException>(() => flagMetadata.GetDouble("wrongKey"));
var result = flagMetadata.GetDouble("wrongKey");

// Assert
Assert.NotNull(exception);
Assert.Equal("Cannot cast System.String to System.Double", exception.Message);
Assert.Null(result);
}

[Fact]
Expand Down Expand Up @@ -241,10 +238,9 @@ public void GetString_Should_Throw_Value_Is_Invalid()
var flagMetadata = new FlagMetadata(metadata);

// Act
var exception = Assert.Throws<InvalidCastException>(() => flagMetadata.GetString("wrongKey"));
var result = flagMetadata.GetString("wrongKey");

// Assert
Assert.NotNull(exception);
Assert.Equal("Cannot cast System.Object to System.String", exception.Message);
Assert.Null(result);
}
}

0 comments on commit 2b2a64f

Please sign in to comment.