public void TestRefresh()
 {
     string tempTile = Path.GetTempFileName();
     File.Copy("a.htm", tempTile, true);
     try
     {
         var ft = new FileTemplate(tempTile);
         Assert.That(ft.TileLastModified, Is.EqualTo(ft.ResourceLastModified));
         File.SetLastWriteTime(tempTile, DateTime.Now.AddDays(-1));
         Assert.That(ft.TileLastModified, Is.Not.EqualTo(ft.ResourceLastModified));
         ft.Refresh();
         Assert.That(ft.TileLastModified, Is.EqualTo(ft.ResourceLastModified));
     }
     finally
     {
         File.Delete(tempTile);
     }
 }
 public void TestRefreshClearsLastError()
 {
     string tempTile = Path.GetTempFileName();
     File.Copy("a.htm", tempTile, true);
     try
     {
         var ft = new FileTemplate(tempTile);
         File.SetLastWriteTime(tempTile, DateTime.Now.AddDays(-1));
         ft.RefreshException=new Exception("Test");
         ft.Refresh();
         Assert.That(ft.RefreshException, Is.Null);
     }
     finally
     {
         File.Delete(tempTile);
     }
 }
 public void TestLastExceptionIsThrownOnParseTemplate()
 {
     var ft = new FileTemplate("a.htm");
     Assert.That(ft.Template, Is.Not.Null);
     ft.RefreshException=new Exception("oops");
     try
     {
         Console.WriteLine(ft.Template);
         Assert.Fail("Should not come here");
     } catch (Exception e)
     {
         Assert.That(e.Message, Is.EqualTo("oops"));
     }
 }
 public void TestLastExceptionIsFilled()
 {
     var tempTile = Path.GetTempFileName();
     File.Copy("a.htm", tempTile, true);
     try
     {
         var ft = new FileTemplate(tempTile);
         Assert.That(ft.TileLastModified, Is.EqualTo(ft.ResourceLastModified));
         File.Delete(tempTile);
         Assert.That(ft.RefreshException, Is.Null);
         ft.Refresh();
         Assert.That(ft.RefreshException, Is.Not.Null);
         Assert.That(ft.RefreshException.Message, Is.EqualTo(TemplateException.TemplateFailedToInitialize(tempTile, ResourceException.FileNotFound(tempTile)).Message));
     }
     finally
     {
         File.Delete(tempTile);
     }
 }
 public void TestDatesOnFileTile()
 {
     var ft = new FileTemplate("a.htm");
     Assert.That(ft.ResourceLastModified, Is.EqualTo(File.GetLastWriteTime("a.htm")));
     Assert.That(ft.TileLastModified, Is.EqualTo(ft.ResourceLastModified));
 }
 public void RequiresRefresh()
 {
     string tempTile = Path.GetTempFileName();
     File.Copy("a.htm", tempTile, true);
     try
     {
         var ft = new FileTemplate(tempTile);
         Assert.That(ft.RequiresRefresh(), Is.False);
         File.SetLastWriteTime(tempTile, DateTime.Now.AddDays(-1));
         Assert.That(ft.RequiresRefresh(), Is.True);
         ft.Refresh();
         Assert.That(ft.RequiresRefresh(), Is.False);
     }
     finally
     {
         File.Delete(tempTile);
     }
 }
        public void HttpErrorCode_Is_Set_On_ResourceException()
        {
            var tempTile = Path.GetTempFileName();
            File.Copy("a.htm", tempTile, true);
            try
            {
                var ft = new FileTemplate(tempTile);
                Assert.That(ft.TileLastModified, Is.EqualTo(ft.ResourceLastModified));
                File.Delete(tempTile);
                ft.Refresh();
                Assert.That(ft.RefreshException, Is.Not.Null);
                Assert.That(((IHaveHttpErrorCode) ft.RefreshException).HttpErrorCode, Is.EqualTo(404));

            }
            finally
            {
                File.Delete(tempTile);
            }
        }