using System.Collections.Generic; using System.Linq; using Moq; using NUnit.Framework; using Umbraco.Cms.Core.Models; using Umbraco.Cms.Core.Services; using Umbraco.Cms.Infrastructure.PublishedCache; using Umbraco.Cms.Tests.Common.Published; using Umbraco.Cms.Tests.UnitTests.TestHelpers; namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Core.Routing; [TestFixture] public abstract class UrlRoutingTestBase : PublishedSnapshotServiceTestBase { [SetUp] public override void Setup() { base.Setup(); var xml = GetXmlContent(1234); IEnumerable kits = PublishedContentXmlAdapter.GetContentNodeKits( xml, TestHelper.ShortStringHelper, out var contentTypes, out var dataTypes).ToList(); InitializedCache(kits, contentTypes, dataTypes); } // Sets up the mock domain service protected override ServiceContext CreateServiceContext(IContentType[] contentTypes, IMediaType[] mediaTypes, IDataType[] dataTypes) { var serviceContext = base.CreateServiceContext(contentTypes, mediaTypes, dataTypes); // setup mock domain service var domainService = Mock.Get(serviceContext.DomainService); domainService.Setup(service => service.GetAll(It.IsAny())) .Returns((bool incWildcards) => new[] { new UmbracoDomain("domain1.com/") { Id = 1, LanguageId = LangDeId, RootContentId = 1001, LanguageIsoCode = "de-DE", }, new UmbracoDomain("domain1.com/en") { Id = 2, LanguageId = LangEngId, RootContentId = 10011, LanguageIsoCode = "en-US", }, new UmbracoDomain("domain1.com/fr") { Id = 3, LanguageId = LangFrId, RootContentId = 10012, LanguageIsoCode = "fr-FR", }, }); return serviceContext; } protected virtual string GetXmlContent(int templateId) => @" ]> This is some content]]> This is some content]]> This is some content]]> This is some content]]> "; public const int LangDeId = 333; public const int LangEngId = 334; public const int LangFrId = 335; public const int LangCzId = 336; public const int LangNlId = 337; public const int LangDkId = 338; }