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 GetView_Should_Update_Locator_Correct() { //Given var lib = new TagLib(); lib.Register(new Html()); lib.Register(new Tiles.Tags.Tiles()); var factory = new FileLocatorFactory("Views").CloneForTagLib(lib); var cache = new NstlCache { Factory = factory }; var view = cache.GetView("Home/Index.htm"); Assert.That(view, Is.Not.Null); var model = new TagModel(new Dictionary<string, string> { { "Message", "Test" } }); Assert.That(view.Render(model).Contains("VIEWS")); //Then }