Пример #1
0
        public void MessageSentEvent()
        {
            ICollection<RawMessage> messages = new List<RawMessage>();

            messages.Add(new RawMessage("THEGAME", "a", "b", "cd ef g"));

            IEnumerator<RawMessage> messageChecker = messages.GetEnumerator();

            var reader = new IO.Helpers.DummyRawMessageReader();
            var writer = new IO.Helpers.DummyRawMessageWriter();

            using(var client = new Ondit.Client.Client(reader, writer)) {
                client.RawMessageSent += delegate(object sender, RawMessageEventArgs e) {
                    bool elementExists = messageChecker.MoveNext();

                    Assert.IsTrue(elementExists);
                    Assert.AreEqual(messageChecker.Current, e.Message);
                };

                foreach(var message in messages) {
                    client.SendMessage(message);
                }
            }
        }
Пример #2
0
        public void MessageSend()
        {
            ICollection<RawMessage> inputMessages = new List<RawMessage>();

            inputMessages.Add(new RawMessage("THEGAME", "a", "b", "cd ef g"));

            string expectedOutput = string.Join("\r\n", inputMessages.Select((message) => message.ToString()).ToArray()) + "\r\n";

            var reader = new IO.Helpers.DummyRawMessageReader();

            using(var stringWriter = new StringWriter())
            using(var writer = new RawMessageTextWriter(stringWriter)) {
                using(var client = new Ondit.Client.Client(reader, writer)) {
                    foreach(var message in inputMessages) {
                        client.SendMessage(message);
                    }

                    Assert.AreEqual(expectedOutput, stringWriter.ToString());
                }
            }
        }