Esempio n. 1
0
        public Tuple<string, string> SaySomethingTo(Actor a)
        {
            Random r = new Random(DateTime.Now.Millisecond);
            string whatISaid = sharedWisdom[r.Next(0, sharedWisdom.Count())];

            string theirPublicKey = a.RequestPublicKey();
            string howIWillSayIt = new BytestringEncryptor(theirPublicKey).EncryptString(whatISaid);
            string whatTheyHeard = a.SayItBackToMe(howIWillSayIt, theirPublicKey);

            return new Tuple<string, string>(whatISaid, whatTheyHeard);
        }
        public void HaveAConversation()
        {
            Actor alice = new Actor("Alice");
            Actor bob = new Actor("Bob");

            Tuple<string, string> conversation = bob.SaySomethingTo(alice);
            Assert.IsTrue(conversation.Item2.Contains(conversation.Item1));

            Debug.WriteLine("Bob said: " + conversation.Item1);
            Debug.WriteLine("Alice responded: " + conversation.Item2);
        }