public void should_check_all_structure() { //arrange var sender = new MessageSender(); var server = new Server(new Encryptor()); var recList = new List<MessageReceiver>(); recList.AddRange(new[] {new MessageReceiver(), new MessageReceiver(), new MessageReceiver()}); recList.ForEach(x=>x.Subscribe(server)); //act server.Subscribe(sender); sender.SendMessage("ku"); //assert recList.ForEach(x => Console.Out.WriteLine("Received: {0}", x.ReceivedMessage)); }
public void server_should_redirect_message() { const string initialMessage = "Hello world"; const string encryptedMessage = "1_2"; var sender = Substitute.For<ISender>(); var enc = Substitute.For<IEncryptor>(); enc.Convert(initialMessage).Returns(encryptedMessage); Console.Out.WriteLine("enc = {0}", enc); var server = new Server(enc); string messageSentToReceiver = null; server.MessageAvailable += (o, args) => messageSentToReceiver = args.Message; server.Subscribe(sender); sender.MessageAvailable += Raise.EventWith(new MsgEventArgs { Message = initialMessage }); messageSentToReceiver.Should().Be(encryptedMessage); }