-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from open-feature/feat/add-spec-complaint-tests
Add spec compliant test suite
- Loading branch information
Showing
27 changed files
with
905 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.ComponentModel; | ||
|
||
namespace OpenFeature.Constant | ||
{ | ||
public enum ErrorType | ||
{ | ||
None, | ||
[Description("PROVIDER_NOT_READY")] | ||
ProviderNotReady, | ||
[Description("FLAG_NOT_FOUND")] | ||
FlagNotFound, | ||
[Description("PARSE_ERROR")] | ||
ParseError, | ||
[Description("TYPE_MISMATCH")] | ||
TypeMismatch, | ||
[Description("GENERAL")] | ||
General | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System; | ||
using OpenFeature.Constant; | ||
using OpenFeature.Extention; | ||
|
||
namespace OpenFeature.Error | ||
{ | ||
public class FeatureProviderException : Exception | ||
{ | ||
public ErrorType ErrorType { get; } | ||
public string ErrorTypeDescription { get; } | ||
|
||
public FeatureProviderException(ErrorType errorType, Exception innerException) | ||
: base(null, innerException) | ||
{ | ||
this.ErrorType = errorType; | ||
this.ErrorTypeDescription = errorType.GetDescription(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
|
||
namespace OpenFeature.Extention | ||
{ | ||
public static class EnumExtensions | ||
{ | ||
public static string GetDescription(this Enum value) | ||
{ | ||
var field = value.GetType().GetField(value.ToString()); | ||
var attribute = field.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault() as DescriptionAttribute; | ||
return attribute?.Description ?? value.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
using OpenFeature.Constant; | ||
|
||
namespace OpenFeature.Model | ||
{ | ||
public class FlagEvaluationDetails<T> | ||
{ | ||
public T Value { get; } | ||
public string FlagKey { get; } | ||
public string ErrorCode { get; } | ||
public ErrorType ErrorType { get; } | ||
public string Reason { get; } | ||
public string Variant { get; } | ||
|
||
public FlagEvaluationDetails(string flagKey, T value, string errorCode, string reason, string variant) | ||
public FlagEvaluationDetails(string flagKey, T value, ErrorType errorType, string reason, string variant) | ||
{ | ||
Value = value; | ||
FlagKey = flagKey; | ||
ErrorCode = errorCode; | ||
Reason = reason; | ||
Variant = variant; | ||
this.Value = value; | ||
this.FlagKey = flagKey; | ||
this.ErrorType = errorType; | ||
this.Reason = reason; | ||
this.Variant = variant; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ public class Metadata | |
|
||
public Metadata(string name) | ||
{ | ||
Name = name; | ||
this.Name = name; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
using OpenFeature.Constant; | ||
|
||
namespace OpenFeature.Model | ||
{ | ||
public class ResolutionDetails<T> | ||
{ | ||
public T Value { get; } | ||
public string FlagKey { get; } | ||
public string ErrorCode { get; } | ||
public ErrorType ErrorType { get; } | ||
public string Reason { get; } | ||
public string Variant { get; } | ||
|
||
public ResolutionDetails(string flagKey, T value, string errorCode = null, string reason = null, string variant = null) | ||
public ResolutionDetails(string flagKey, T value, ErrorType errorType = ErrorType.None, string reason = null, string variant = null) | ||
{ | ||
Value = value; | ||
FlagKey = flagKey; | ||
ErrorCode = errorCode; | ||
Reason = reason; | ||
Variant = variant; | ||
this.Value = value; | ||
this.FlagKey = flagKey; | ||
this.ErrorType = errorType; | ||
this.Reason = reason; | ||
this.Variant = variant; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.