public void DomainEventMustBeProducedForRoleLeaderChanges() { var g0 = Gossip.Empty; var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, dLeaving, eJoining)); var g2 = new Gossip(ImmutableSortedSet.Create(bUp, cUp, dExiting, eJoining)); var expected = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", aUp.Address), new ClusterEvent.RoleLeaderChanged("AB", aUp.Address), new ClusterEvent.RoleLeaderChanged("BB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DD", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("DE", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("EE", eUp.Address) ); Assert.Equal(expected, ClusterEvent.DiffRolesLeader(g0, g1, selfDummyAddress)); var expected2 = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", null), new ClusterEvent.RoleLeaderChanged("AB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DE", eJoining.Address) ); Assert.Equal(expected2, ClusterEvent.DiffRolesLeader(g1, g2, selfDummyAddress)); }
public void DomainEvents_must_be_produced_for_role_leader_changes() { var g0 = Gossip.Empty; var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, dLeaving, eJoining)); var g2 = new Gossip(ImmutableSortedSet.Create(bUp, cUp, dExiting, eJoining)); var expected = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", aUp.Address), new ClusterEvent.RoleLeaderChanged("AB", aUp.Address), new ClusterEvent.RoleLeaderChanged("BB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DD", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("DE", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("EE", eUp.Address)); ClusterEvent.DiffRolesLeader(g0, g1, selfDummyAddress).Should().BeEquivalentTo(expected); var expected2 = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", null), new ClusterEvent.RoleLeaderChanged("AB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DE", eJoining.Address)); ClusterEvent.DiffRolesLeader(g1, g2, selfDummyAddress).Should().BeEquivalentTo(expected2); }