public void MembershipWithIncludesAndExcludes() { var m0 = NewMembershipFromSegmentRefs( new string[] { "key1", "key2" }, new string[] { "key2", "key3" } ); // key1 is included; key2 is included and excluded, therefore it's included; key3 is excluded var m1 = NewMembershipFromSegmentRefs( new string[] { "key2", "key1" }, new string[] { "key3", "key2" } ); Assert.NotSame(m0, m1); TypeBehavior.AssertEqual(m0, m0); Assert.True(m0.CheckMembership("key1")); Assert.True(m0.CheckMembership("key2")); Assert.False(m0.CheckMembership("key3")); Assert.Null(m0.CheckMembership("key4")); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs( new string[] { "key1", "key2" }, new string[] { "key2", "key3", "key4" })); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs( new string[] { "key1", "key2", "key3" }, new string[] { "key2", "key3" })); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(new string[] { "key1" }, null)); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(null, null)); }
public void MembershipWithSingleExcludeOnly() { var m0 = NewMembershipFromSegmentRefs(null, new string[] { "key1" }); var m1 = NewMembershipFromSegmentRefs(null, new string[] { "key1" }); Assert.NotSame(m0, m1); TypeBehavior.AssertEqual(m0, m1); Assert.False(m0.CheckMembership("key1")); Assert.Null(m0.CheckMembership("key2")); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(new string[] { "key1" }, null)); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(null, new string[] { "key2" })); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(null, null)); }
public void MembershipWithMultipleIncludesOnly() { var m0 = NewMembershipFromSegmentRefs(new string[] { "key1", "key2" }, null); var m1 = NewMembershipFromSegmentRefs(new string[] { "key2", "key1" }, null); Assert.NotSame(m0, m1); TypeBehavior.AssertEqual(m0, m1); Assert.True(m0.CheckMembership("key1")); Assert.True(m0.CheckMembership("key2")); Assert.Null(m0.CheckMembership("key3")); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs( new string[] { "key1", "key2" }, new string[] { "key3" })); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs( new string[] { "key1", "key3" }, null)); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(new string[] { "key1" }, null)); TypeBehavior.AssertNotEqual(m0, NewMembershipFromSegmentRefs(null, null)); }