Files
Umbraco-CMS/tests/Umbraco.Tests/Routing/RoutesCacheTests.cs
Paul Johnson 00133e880d Move test projects from src/ to tests/ (#11357)
* Update gitignore

* Move csproj

* Update project references

* Update solutions

* Update build scripts

* Tests used to share editorconfig with projects in src

* Fix broken tests.

* Stop copying around .editorconfig

merged root one with linting

* csharp_style_expression_bodied -> suggestion

* Move StyleCop rulesets to matching directories and update shared build properties

* Remove legacy build files, update NuGet.cofig and solution files

* Restore myget source

* Clean up .gitignore

* Update .gitignore

* Move new test classes to tests after merge

* Gitignore + nuget config

* Move new test

Co-authored-by: Ronald Barendse <ronald@barend.se>
2021-10-18 08:14:04 +01:00

46 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using Umbraco.Cms.Tests.Common.Testing;
using Umbraco.Tests.LegacyXmlPublishedCache;
using Umbraco.Tests.TestHelpers;
using Umbraco.Tests.Testing;
namespace Umbraco.Tests.Routing
{
[TestFixture]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerFixture)]
public class RoutesCacheTests : BaseWebTest
{
[Test]
public void U4_7939()
{
//var routingContext = GetRoutingContext("/test", 1111);
var umbracoContext = GetUmbracoContext("/test", 0);
var cache = umbracoContext.PublishedSnapshot.Content as PublishedContentCache;
if (cache == null) throw new Exception("Unsupported IPublishedContentCache, only the Xml one is supported.");
// FIXME: not sure?
//PublishedContentCache.UnitTesting = false; // else does not write to routes cache
//Assert.IsFalse(PublishedContentCache.UnitTesting);
var z = cache.GetByRoute(false, "/home/sub1");
Assert.IsNotNull(z);
Assert.AreEqual(1173, z.Id);
var routes = cache.RoutesCache.GetCachedRoutes();
Assert.AreEqual(1, routes.Count);
// before the fix, the following assert would fail because the route would
// have been stored as { 0, "/home/sub1" } - essentially meaning we were NOT
// storing anything in the route cache!
Assert.AreEqual(1173, routes.Keys.First());
Assert.AreEqual("/home/sub1", routes.Values.First());
}
}
}