Exemple #1
0
        //共通処理(バナーチェック)  Resharperのバージョンを吸収
//        private void CheckBanner(string str) {
//            //テストの際は、バージョン番号はテストツール(ReSharper)のバージョンになる
//            const string bannerStr1 = "xxx";
//            const string bannerStr2 = "+OK BlackJumboDog (Version 7.1.2000.1478) ready <";
//
//
//            //Assert.That(_v6cl.StringRecv(3, this), Is.EqualTo(BannerStr));
//
//            if (str != bannerStr1 && str.IndexOf(bannerStr2) != 0) {
//                Assert.Fail();
//            }
//        }
//
        //共通処理(ログイン成功)
        //ユーザ名、メール蓄積数、蓄積サイズ
        void Login(string userName, string password, int n, int size, SockTcp cl)
        {
            Assert.That(cl.StringRecv(3, this), Is.EqualTo("+OK \r\n"));
            cl.StringSend(string.Format("USER {0}", userName));
            Assert.That(cl.StringRecv(3, this), Is.EqualTo(string.Format("+OK Password required for {0}.\r\n", userName)));
            cl.StringSend(string.Format("PASS {0}", password));
            Assert.That(cl.StringRecv(10, this), Is.EqualTo(string.Format("+OK {0} has {1} message ({2} octets).\r\n", userName, n, size)));
        }
Exemple #2
0
        //共通処理(ログイン成功)
        private void Login(string userName, SockTcp cl)
        {
            CheckBanner(cl.StringRecv(1, this));//バナーチェック

            cl.StringSend(string.Format("USER {0}", userName));
            Assert.That(cl.StringRecv(1, this), Is.EqualTo(string.Format("331 Password required for {0}.\r\n", userName)));
            cl.StringSend(string.Format("PASS {0}", userName));
            Assert.That(cl.StringRecv(10, this), Is.EqualTo(string.Format("230 User {0} logged in.\r\n", userName)));
        }
Exemple #3
0
        private void Ehlo(SockTcp cl)
        {
            var localPort = cl.LocalAddress.Port; //なぜかローカルのポートアドレスは1つ小さい

            //バナー
            const string bannerStr = "220 localhost SMTP BlackJumboDog ";

            Assert.That(cl.StringRecv(3, this).Substring(0, 33), Is.EqualTo(bannerStr));

            //EHLO
            cl.StringSend("EHLO 1");
            var lines = Inet.RecvLines(cl, 4, this);

            var str = string.Format("250-localhost Helo 127.0.0.1[127.0.0.1:{0}], Pleased to meet you.", localPort);

            if (cl.LocalAddress.Address.ToString() == "::1")
            {
                str = string.Format("250-localhost Helo ::1[[::1]:{0}], Pleased to meet you.", localPort);
            }
            Assert.That(lines[0], Is.EqualTo(str));
            Assert.That(lines[1], Is.EqualTo("250-8BITMIME"));
            Assert.That(lines[2], Is.EqualTo("250-SIZE=5000"));
            Assert.That(lines[3], Is.EqualTo("250-AUTH LOGIN PLAIN CRAM-MD5"));
            Assert.That(lines[4], Is.EqualTo("250 HELP"));
        }
Exemple #4
0
        public void EchoサーバにstringSendで1行送信してstringRecvで1行受信する()
        {
            //setUp
            const string addr = "127.0.0.1";
            const int    port = 9993;

            var sv = new EchoServer(addr, port);

            sv.Start();
            var sut = new SockTcp(new Kernel(), new Ip(addr), port, 100, null);

            sut.StringSend("本日は晴天なり", "UTF-8");
            Thread.Sleep(10);

            var expected = "本日は晴天なり\r\n";

            //exercise
            var actual = sut.StringRecv("UTF-8", 1, this);

            //verify
            Assert.That(actual, Is.EqualTo(expected));

            //tearDown
            sut.Close();
            sv.Stop();
        }
Exemple #5
0
        private void Helo(SockTcp cl)
        {
            var localPort = cl.LocalAddress.Port; //なぜかローカルのポートアドレスは1つ小さい

            //バナー
            const string bannerStr = "220 localhost SMTP BlackJumboDog ";

            Assert.That(cl.StringRecv(3, this).Substring(0, 33), Is.EqualTo(bannerStr));

            //HELO
            cl.StringSend("HELO 1");

            var str = string.Format("250 localhost Helo 127.0.0.1[127.0.0.1:{0}], Pleased to meet you.\r\n", localPort);

            if (cl.LocalAddress.Address.ToString() == "::1")
            {
                str = string.Format("250 localhost Helo ::1[[::1]:{0}], Pleased to meet you.\r\n", localPort);
            }
            Assert.That(cl.StringRecv(3, this), Is.EqualTo(str));
        }