public void TestEqualityAndHashCode()
 {
     TypeBehavior.CheckEqualsAndHashCode(
         // each value in this list should be unequal to all the other values and equal to itself
         () => EvaluationReason.OffReason,
         () => EvaluationReason.FallthroughReason,
         () => EvaluationReason.FallthroughReason.WithInExperiment(true),
         () => EvaluationReason.RuleMatchReason(0, "rule1"),
         () => EvaluationReason.RuleMatchReason(0, "rule1").WithInExperiment(true),
         () => EvaluationReason.RuleMatchReason(0, "rule1").WithBigSegmentsStatus(BigSegmentsStatus.Stale),
         () => EvaluationReason.RuleMatchReason(1, "rule2"),
         () => EvaluationReason.PrerequisiteFailedReason("a"),
         () => EvaluationReason.PrerequisiteFailedReason("b"),
         () => EvaluationReason.ErrorReason(EvaluationErrorKind.FlagNotFound),
         () => EvaluationReason.ErrorReason(EvaluationErrorKind.Exception)
         );
 }
 public void TestReasonSerializationDeserialization()
 {
     foreach (var test in new ReasonTestCase[]
     {
         new ReasonTestCase {
             Reason = EvaluationReason.OffReason,
             JsonString = @"{""kind"":""OFF""}", ExpectedShortString = "OFF"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.FallthroughReason,
             JsonString = @"{""kind"":""FALLTHROUGH""}", ExpectedShortString = "FALLTHROUGH"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.FallthroughReason.WithInExperiment(true),
             JsonString = @"{""kind"":""FALLTHROUGH"",""inExperiment"":true}",
             ExpectedShortString = "FALLTHROUGH"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.FallthroughReason.WithBigSegmentsStatus(BigSegmentsStatus.Healthy),
             JsonString = @"{""kind"":""FALLTHROUGH"",""bigSegmentsStatus"":""HEALTHY""}", ExpectedShortString = "FALLTHROUGH"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.FallthroughReason.WithInExperiment(true).WithBigSegmentsStatus(BigSegmentsStatus.Healthy),
             JsonString = @"{""kind"":""FALLTHROUGH"",""inExperiment"":true,""bigSegmentsStatus"":""HEALTHY""}",
             ExpectedShortString = "FALLTHROUGH"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.TargetMatchReason,
             JsonString = @"{""kind"":""TARGET_MATCH""}", ExpectedShortString = "TARGET_MATCH"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.RuleMatchReason(1, "id"),
             JsonString = @"{""kind"":""RULE_MATCH"",""ruleIndex"":1,""ruleId"":""id""}",
             ExpectedShortString = "RULE_MATCH(1,id)"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.RuleMatchReason(1, "id").WithInExperiment(true),
             JsonString = @"{""kind"":""RULE_MATCH"",""ruleIndex"":1,""ruleId"":""id"",""inExperiment"":true}",
             ExpectedShortString = "RULE_MATCH(1,id)"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.RuleMatchReason(1, "id").WithBigSegmentsStatus(BigSegmentsStatus.Healthy),
             JsonString = @"{""kind"":""RULE_MATCH"",""ruleIndex"":1,""ruleId"":""id"",""bigSegmentsStatus"":""HEALTHY""}",
             ExpectedShortString = "RULE_MATCH(1,id)"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.RuleMatchReason(1, "id").WithInExperiment(true).WithBigSegmentsStatus(BigSegmentsStatus.Healthy),
             JsonString = @"{""kind"":""RULE_MATCH"",""ruleIndex"":1,""ruleId"":""id"",""inExperiment"":true,""bigSegmentsStatus"":""HEALTHY""}",
             ExpectedShortString = "RULE_MATCH(1,id)"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.PrerequisiteFailedReason("key"),
             JsonString = @"{""kind"":""PREREQUISITE_FAILED"",""prerequisiteKey"":""key""}",
             ExpectedShortString = "PREREQUISITE_FAILED(key)"
         },
         new ReasonTestCase {
             Reason = EvaluationReason.ErrorReason(EvaluationErrorKind.Exception),
             JsonString = @"{""kind"":""ERROR"",""errorKind"":""EXCEPTION""}",
             ExpectedShortString = "ERROR(EXCEPTION)"
         }
     })
     {
         AssertJsonEqual(test.JsonString, LdJsonSerialization.SerializeObject(test.Reason));
         Assert.Equal(test.Reason, LdJsonSerialization.DeserializeObject <EvaluationReason>(test.JsonString));
         Assert.Equal(test.ExpectedShortString, test.Reason.ToString());
     }
 }