public void GetSelectionResultTest1() { var target = new AllMemberSelectionRule(MemberSelectionMode.Exclude); const MemberSelectionResult expected = MemberSelectionResult.ExcludeMember; var actual = target.GetSelectionResult(new MemberInformation()); actual.Should() .Be(expected); }
public void InspectNoRulesTest() { var target = new MemberSelectionRuleInspector(); const MemberSelectionResult expected = MemberSelectionResult.Neutral; var actual = target.Inspect(new List <IMemberSelectionRule>(), new MemberInformation()); actual.Should() .Be(expected); }
public void PredicateTrueIncludeTest() { var target = new ExpressionMemberSelectionRule(x => true, MemberSelectionMode.Include); const MemberSelectionResult expected = MemberSelectionResult.IncludeMember; var actual = target.GetSelectionResult(new MemberInformation()); actual.Should() .Be(expected); }
public void PredicateFalseExcludeTest() { var target = new ExpressionMemberSelectionRule(x => false, MemberSelectionMode.Exclude); const MemberSelectionResult expected = MemberSelectionResult.Neutral; var actual = target.GetSelectionResult(new MemberInformation()); actual.Should() .Be(expected); }
public void GetSelectionResultTest4() { var target = new TypeMemberSelectionRule(typeof(String), MemberSelectionMode.Exclude, CompareMode.Is); const MemberSelectionResult expected = MemberSelectionResult.ExcludeMember; var actual = target.GetSelectionResult(new MemberInformation { MemberType = typeof(String) }); actual.Should() .Be(expected); }
public void GetSelectionResultTest3() { var target = new PathMemberSelectionRule("A.B.C", MemberSelectionMode.Exclude); const MemberSelectionResult expected = MemberSelectionResult.Neutral; var actual = target.GetSelectionResult(new MemberInformation { MemberPath = "A.B.C.MyString" }); actual.Should() .Be(expected); }
public void InspectIncludeOnlyTest() { var target = new MemberSelectionRuleInspector(); const MemberSelectionResult expected = MemberSelectionResult.IncludeMember; var actual = target.Inspect(new List <IMemberSelectionRule> { new ExpressionMemberSelectionRule(x => true, MemberSelectionMode.Include) }, new MemberInformation()); actual.Should() .Be(expected); }
public void InspectNoMatchingRulesTest() { var target = new MemberSelectionRuleInspector(); const MemberSelectionResult expected = MemberSelectionResult.Neutral; var actual = target.Inspect(new List <IMemberSelectionRule> { new ExpressionMemberSelectionRule(x => false, MemberSelectionMode.Include), new ExpressionMemberSelectionRule(x => false, MemberSelectionMode.Exclude) }, new MemberInformation()); actual.Should() .Be(expected); }
/// <summary> /// Converts the given <see cref="MemberSelectionResult" /> to a boolean value indicating whether to include or not. /// </summary> /// <param name="memberSelectionResult">The <see cref="MemberSelectionResult" /> to convert.</param> /// <returns>Returns the boolean value of the given <see cref="MemberSelectionResult" />.</returns> public static Boolean?AsBoolean(this MemberSelectionResult memberSelectionResult) { switch (memberSelectionResult) { case MemberSelectionResult.IncludeMember: return(true); case MemberSelectionResult.ExcludeMember: return(false); case MemberSelectionResult.Neutral: return(null); default: // This line can not be unit tested throw new ArgumentOutOfRangeException(nameof(memberSelectionResult), memberSelectionResult, $"The member selection result '{memberSelectionResult}' is not supported."); } }