public void GetView_Should_Be_Cached() { //Given var cache = new NstlCache(); cache.GuardInit(typeof (TilesViewEngineTest).Assembly); Assert.That(cache.Factory.Handle("mvc_Index.htm", false), Is.Not.Null); //Then Assert.That(cache.GetView("mvc_Index.htm"), Is.SameAs(cache.GetView("mvc_Index.htm"))); }
public void GetView_Should_Return_View_From_Factory() { //Given var cache = new NstlCache(); cache.GuardInit(typeof (TilesViewEngineTest).Assembly); Assert.That(cache.Factory.Handle("mvc_Index.htm", false), Is.Not.Null); Assert.That(!cache.Pages.Contains("mvc_Index.htm")); //Then Assert.That(cache.GetView("mvc_Index.htm").Name, Is.EqualTo(cache.Factory.Handle("mvc_Index.htm", false).Path)); }
public void GetView_Should_Retun_False_On_Unkown_View() { var cache = new NstlCache(); cache.GuardInit(typeof (TilesViewEngineTest).Assembly); try { cache.GetView("wrong"); Assert.Fail("Expected exception"); } catch (TemplateException e) { Assert.That(e.HttpErrorCode, Is.EqualTo(404)); } }
public void TestInit() { var cache = new NstlCache(); Assert.That(cache.Pages, Is.Not.Null); Assert.That(cache.Pages.Tiles, Is.Empty); Assert.That(cache.Factory, Is.Null); cache.GuardInit(typeof (TilesViewEngineTest).Assembly); Assert.That(cache.Factory, Is.Not.Null); Assert.That(cache.Pages.Tiles, Is.Empty); }
public void HasView_Should_Use_PostFix() { NstlCache.PostFix = ".htm"; //Given var cache = new NstlCache(); cache.GuardInit(typeof(TilesViewEngineTest).Assembly); Assert.That(cache.Factory.Handle("mvc_Index.htm", true), Is.Not.Null); Assert.That(!cache.Pages.Contains("mvc_Index.htm")); //Then Assert.That(cache.HasView("mvc_Index")); }
public void HasView_Should_Retun_False_On_Unkown_View() { //Given var cache = new NstlCache(); cache.GuardInit(typeof (TilesViewEngineTest).Assembly); Assert.That(cache.Factory.Handle("Wrong.htm", false), Is.Null); Assert.That(!cache.Pages.Contains("Wrong.htm")); //Then Assert.That(!cache.HasView("Wrong")); }