Exemplo n.º 1
0
        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")));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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"));
        }
Exemplo n.º 4
0
        public void HasView_Should_Be_Based_On_Locator()
        {
            //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.htm"));
        }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
        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));
            }
        }
Exemplo n.º 7
0
        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
        }