2020-12-20 08:36:11 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Cache;
|
|
|
|
|
using Umbraco.Cms.Core.Macros;
|
|
|
|
|
using Umbraco.Cms.Web.Common.Macros;
|
2018-06-29 19:52:40 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common.Macros;
|
|
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class MacroTests
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
[SetUp]
|
|
|
|
|
public void Setup()
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
// We DO want cache enabled for these tests
|
|
|
|
|
var cacheHelper = new AppCaches(
|
|
|
|
|
new ObjectCacheAppCache(),
|
|
|
|
|
NoAppCache.Instance,
|
|
|
|
|
new IsolatedCaches(type => new ObjectCacheAppCache()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TestCase("anything", true)]
|
|
|
|
|
[TestCase("", false)]
|
|
|
|
|
public void Macro_Is_File_Based(string macroSource, bool expectedNonNull)
|
|
|
|
|
{
|
|
|
|
|
var model = new MacroModel { MacroSource = macroSource };
|
|
|
|
|
var filename = MacroRenderer.GetMacroFileName(model);
|
|
|
|
|
if (expectedNonNull)
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
Assert.IsNotNull(filename);
|
2018-06-29 19:52:40 +02:00
|
|
|
}
|
2022-06-21 08:09:38 +02:00
|
|
|
else
|
2018-06-29 19:52:40 +02:00
|
|
|
{
|
2022-06-21 08:09:38 +02:00
|
|
|
Assert.IsNull(filename);
|
2018-06-29 19:52:40 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|