public void AGossipMustMergeMembersByStatusPriority() { var g1 = Gossip.Create(ImmutableSortedSet.Create(a1, c1, e1)); var g2 = Gossip.Create(ImmutableSortedSet.Create(a2, c2, e2)); var merged1 = g1.Merge(g2); Assert.Equal(ImmutableSortedSet.Create(a2, c1, e1), merged1.Members); Assert.Equal(new [] { MemberStatus.Up, MemberStatus.Leaving, MemberStatus.Up }, merged1.Members.Select(m => m.Status).ToArray()); var merged2 = g2.Merge(g1); Assert.Equal(ImmutableSortedSet.Create(a2, c1, e1), merged2.Members); Assert.Equal(new [] { MemberStatus.Up, MemberStatus.Leaving, MemberStatus.Up }, merged2.Members.Select(m => m.Status).ToArray()); }
public void A_gossip_must_merge_members_by_status_priority() { var g1 = Gossip.Create(ImmutableSortedSet.Create(a1, c1, e1)); var g2 = Gossip.Create(ImmutableSortedSet.Create(a2, c2, e2)); var merged1 = g1.Merge(g2); merged1.Members.Should().BeEquivalentTo(ImmutableSortedSet.Create(a2, c1, e1)); merged1.Members.Select(c => c.Status).ToImmutableList().Should() .BeEquivalentTo(ImmutableList.Create(MemberStatus.Up, MemberStatus.Leaving, MemberStatus.Up)); var merged2 = g2.Merge(g1); merged2.Members.Should().BeEquivalentTo(ImmutableSortedSet.Create(a2, c1, e1)); merged2.Members.Select(c => c.Status).ToImmutableList().Should() .BeEquivalentTo(ImmutableList.Create(MemberStatus.Up, MemberStatus.Leaving, MemberStatus.Up)); }