static void Main(string[] args) { var med = new Mediator(); var p1 = new Participant(med) { Value = 0 }; var p2 = new Participant(med) { Value = 0 }; p1.Say(3); WriteLine($"p1 = {p1.Value}, p2 = {p2.Value}"); p2.Say(2); WriteLine($"p1 = {p1.Value}, p2 = {p2.Value}"); }
public static void Main() { var mediator = new Mediator(); var participant1 = new Participant(mediator); var participant2 = new Participant(mediator); mediator.AddParticipant(participant1); mediator.AddParticipant(participant2); var say1 = 3; var say2 = 2; Assert.Equal(participant1.Value, 0); Assert.Equal(participant2.Value, 0); participant1.Say(say1); Assert.Equal(participant1.Value, 0); Assert.Equal(participant2.Value, say1); participant2.Say(say2); Assert.Equal(participant1.Value, say2); Assert.Equal(participant2.Value, say1); }