Exemple #1
0
 private void Cleanup()
 {
     homeController?.Dispose();
     homeController = null;
     MailDemonDatabase.DeleteDatabase(true);
     sentMailCount = 0;
     mailCreator   = null;
 }
Exemple #2
0
 public void Setup()
 {
     TearDown();
     using (var db = new MailDemonDatabase())
     {
         db.Initialize();
     }
     viewRenderer = new RazorRenderer(Path.Combine(Directory.GetCurrentDirectory(), "../../.."));
 }
 public void Setup()
 {
     TearDown();
     using (var db = new MailDemonDatabase())
     {
         db.Initialize();
     }
     viewRenderer = new RazorRenderer(null, Directory.GetCurrentDirectory(),
                                      Assembly.GetExecutingAssembly());
 }
        public void TestTemplateCacheDatabase()
        {
            MailTemplate template = new MailTemplate {
                Name = "test", Text = "<b>Hello World</b> @Model.FirstName"
            };

            using (var db = new MailDemonDatabase())
            {
                db.Lists.Add(new MailList {
                    Name = "test"
                });
                db.Templates.Add(template);
                db.SaveChanges();
            }

            string html = viewRenderer.RenderViewToStringAsync("test", model, isMainPage: false).Sync();

            Assert.AreEqual("<b>Hello World</b> Bob", html);
            html = viewRenderer.RenderViewToStringAsync("test", model, isMainPage: false).Sync();
            Assert.AreEqual("<b>Hello World</b> Bob", html);

            template.Text        += " <br/>New Line<br/>";
            template.LastModified = DateTime.UtcNow;
            template.Dirty        = true;

            using (var db = new MailDemonDatabase())
            {
                db.Update(template);
                db.SaveChanges();
            }

            html = viewRenderer.RenderViewToStringAsync("test", model, isMainPage: false).Sync();
            Assert.AreEqual("<b>Hello World</b> Bob <br/>New Line<br/>", html);
            html = viewRenderer.RenderViewToStringAsync("test", model, isMainPage: false).Sync();
            Assert.AreEqual("<b>Hello World</b> Bob <br/>New Line<br/>", html);
        }
 public void TearDown()
 {
     MailDemonDatabase.DeleteDatabase(true);
 }