public void Save0Test(string body, string subject) { // ドメインを追加 const string domain = "@example.com"; const string from = "user1" + domain; var mail = new TsMail(from, "1ban-ctl" + domain, body); _ml.Job(mail.MlEnvelope, mail.Mail); Assert.AreEqual(_tsMailSave.Count(), 1); //返されるエラーメールは1通 Assert.AreEqual(_tsMailSave.GetMail(0).GetHeader("subject"), subject); Assert.AreEqual(_tsMailSave.GetFrom(0).ToString(), "1ban-admin" + domain); }
[TestCase(10)]//10通の送信 //[TestCase(10000)]//10000通の送信(時間がかかるので、デバッグ時のみ使用する) public void Save30Test(int count) { const string domain = "@example.com"; const string from = "user1" + domain; for (var i = 0; i < count; i++) { var m = new TsMail(from, "1ban" + domain, "DMY"); var subject = string.Format("TEST_{0}", i);//試験的に件名を挿入する m.Mail.AddHeader("subject", subject); _ml.Job(m.MlEnvelope, m.Mail); } //この時点で、user1,user2,adin2のそれぞれ30通が送信されているため_tsMailSave.Count()は90となる Assert.AreEqual(_tsMailSave.Count(), count * 3); for (var i = 0; i < _tsMailSave.Count(); i++) { var mail = _tsMailSave.GetMail(i); Assert.AreEqual(mail.GetHeader("from"), from); Assert.AreEqual(mail.GetHeader("to"), "1ban" + domain); Assert.AreEqual(mail.GetHeader("subject"), string.Format("[1ban:{0:D5}] TEST_{1}", i / 3 + 1, i / 3)); Assert.AreEqual(mail.GetHeader("Reply-To"), "\"1ban\"<*****@*****.**>"); Assert.AreEqual(mail.GetHeader("List-Id"), "1ban.example.com"); Assert.AreEqual(mail.GetHeader("List-Post"), "<mailto:[email protected]>"); Assert.AreEqual(mail.GetHeader("List-Owner"), "<mailto:[email protected]>"); Assert.AreEqual(mail.GetHeader("List-Help"), "<mailto:[email protected]?body=help>"); Assert.AreEqual(mail.GetHeader("List-Unsubscribe"), "<mailto:[email protected]?body=unsubscribe>"); } }
[TestCase("xxxx")] //メンバ外からのリクエスト(メンバ外からもguideは取得できる public void GuideTest(string user) { // ドメインを追加 const string domain = "@example.com"; var from = user + domain; var mail = new TsMail(from, "1ban-ctl" + domain, "guide"); _ml.Job(mail.MlEnvelope, mail.Mail); Assert.AreEqual(_tsMailSave.Count(), 1); var m = _tsMailSave.GetMail(0); //送信者 Assert.AreEqual(m.GetHeader("from"), "1ban-admin" + domain); //件名 Assert.AreEqual(m.GetHeader("subject"), "guide (1ban ML)"); }
public void AdminTest(string from) { var mail = new TsMail(from, "*****@*****.**", "DMY"); _ml.Job(mail.MlEnvelope, mail.Mail); //管理者全員にメールが配信される Assert.AreEqual(_tsMailSave.Count(), 2); //送信者の確認 Assert.AreEqual(_tsMailSave.GetMail(0).GetHeader("from"), from); }