public void It_Should_Not_Cache_Dissimilar_Templates()
        {
            // Arrange
            String tmpl = "test";
            MockGenerator mockGenerator = new MockGenerator();
            var cachingGenerator = new CachingLiquidASTGenerator(mockGenerator);

            // Act
            var result1 = cachingGenerator.Generate(tmpl);
            var result2 = cachingGenerator.Generate(tmpl + "2");

            // Assert
            Assert.That(result1, Is.Not.Null);
            Assert.That(result2, Is.Not.Null);
            Assert.That(mockGenerator.Calls, Is.EqualTo(2));
        }
        public void It_Should_Cache_A_Template()
        {
            // Arrange
            String tmpl = "<html>{{Test}}</html>";
            MockGenerator mockGenerator = new MockGenerator();
            var cachingGenerator = new CachingLiquidASTGenerator(mockGenerator);
            
            // Act
            var result1= cachingGenerator.Generate(tmpl);
            var result2 = cachingGenerator.Generate(tmpl);

            // Assert
            Assert.That(result1, Is.Not.Null);
            Assert.That(result2, Is.Not.Null);
            Assert.That(mockGenerator.Calls, Is.EqualTo(1));
        }
        public void It_Should_Cache_A_Template()
        {
            // Arrange
            String        tmpl             = "<html>{{Test}}</html>";
            MockGenerator mockGenerator    = new MockGenerator();
            var           cachingGenerator = new CachingLiquidASTGenerator(mockGenerator);

            // Act
            var result1 = cachingGenerator.Generate(tmpl);
            var result2 = cachingGenerator.Generate(tmpl);

            // Assert
            Assert.NotNull(result1);
            Assert.NotNull(result2);
            Assert.Equal(1, mockGenerator.Calls);
        }
        public void It_Should_Not_Cache_Dissimilar_Templates()
        {
            // Arrange
            String        tmpl             = "test";
            MockGenerator mockGenerator    = new MockGenerator();
            var           cachingGenerator = new CachingLiquidASTGenerator(mockGenerator);

            // Act
            var result1 = cachingGenerator.Generate(tmpl);
            var result2 = cachingGenerator.Generate(tmpl + "2");

            // Assert
            Assert.NotNull(result1);
            Assert.NotNull(result2);
            Assert.Equal(2, mockGenerator.Calls);
        }
        public void It_Should_Not_Cache_Erroring_Templates()
        {
            // Arrange
            String tmpl          = "Result: {% weofijwef";
            var    mockGenerator = new MockGeneratorWithError(new LiquidError {
                Message = "Bad Things Happened!"
            });
            var cachingGenerator = new CachingLiquidASTGenerator(mockGenerator);

            // Act
            var result1 = cachingGenerator.Generate(tmpl, err => { });
            var result2 = cachingGenerator.Generate(tmpl, err => { });

            // Assert
            Assert.NotNull(result1);
            Assert.NotNull(result2);
            Assert.Equal(2, mockGenerator.Calls);
        }
        public void It_Should_Cache_A_Template_Across_Objects()
        {
            // Arrange
            String tmpl = "<html>{{Test 2}}</html>";
            MockGenerator mockGenerator = new MockGenerator();
            var cachingGenerator = new CachingLiquidASTGenerator(mockGenerator);
            var cachingGenerator2 = new CachingLiquidASTGenerator(mockGenerator);

            // Act
            cachingGenerator.Generate(tmpl);
            cachingGenerator2.Generate(tmpl);

            // Assert
            Assert.That(mockGenerator.Calls, Is.EqualTo(1));
        }
        public void It_Should_Cache_A_Template_Across_Objects()
        {
            // Arrange
            String        tmpl              = "<html>{{Test 2}}</html>";
            MockGenerator mockGenerator     = new MockGenerator();
            var           cachingGenerator  = new CachingLiquidASTGenerator(mockGenerator);
            var           cachingGenerator2 = new CachingLiquidASTGenerator(mockGenerator);

            // Act
            cachingGenerator.Generate(tmpl);
            cachingGenerator2.Generate(tmpl);

            // Assert
            Assert.Equal(1, mockGenerator.Calls);
        }