Example #1
0
 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);
     }
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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);
     }
 }
Example #4
0
 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);
     }
 }
Example #5
0
        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);
            }
        }