2020-08-26 07:55:23 +02:00
|
|
|
|
using System.Linq;
|
2020-10-27 10:53:01 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-08-26 07:55:23 +02:00
|
|
|
|
using Moq;
|
2021-02-09 10:22:42 +01:00
|
|
|
|
using Umbraco.Cms.Core.Configuration.Models;
|
|
|
|
|
|
using Umbraco.Cms.Core.Models.PublishedContent;
|
|
|
|
|
|
using Umbraco.Cms.Core.Routing;
|
|
|
|
|
|
using Umbraco.Cms.Core.Web;
|
2021-02-10 14:45:44 +01:00
|
|
|
|
using Umbraco.Cms.Tests.Common;
|
2020-08-26 07:55:23 +02:00
|
|
|
|
using Umbraco.Tests.TestHelpers;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Umbraco.Tests.Routing
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract class BaseUrlProviderTest : BaseWebTest
|
|
|
|
|
|
{
|
|
|
|
|
|
protected IUmbracoContextAccessor UmbracoContextAccessor { get; } = new TestUmbracoContextAccessor();
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract bool HideTopLevelNodeFromPath { get; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Compose()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Compose();
|
2021-04-22 20:25:25 +10:00
|
|
|
|
Builder.Services.AddTransient<ISiteDomainMapper, SiteDomainMapper>();
|
2020-08-26 07:55:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void ComposeSettings()
|
|
|
|
|
|
{
|
2020-09-21 21:06:24 +02:00
|
|
|
|
var contentSettings = new ContentSettings();
|
|
|
|
|
|
var userPasswordConfigurationSettings = new UserPasswordConfigurationSettings();
|
2020-08-26 07:55:23 +02:00
|
|
|
|
|
2020-11-18 17:40:23 +00:00
|
|
|
|
Builder.Services.AddTransient(x => Microsoft.Extensions.Options.Options.Create(contentSettings));
|
|
|
|
|
|
Builder.Services.AddTransient(x => Microsoft.Extensions.Options.Options.Create(userPasswordConfigurationSettings));
|
2020-08-26 07:55:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected IPublishedUrlProvider GetPublishedUrlProvider(IUmbracoContext umbracoContext, DefaultUrlProvider urlProvider)
|
|
|
|
|
|
{
|
2020-09-21 21:06:24 +02:00
|
|
|
|
var webRoutingSettings = new WebRoutingSettings();
|
2020-08-26 07:55:23 +02:00
|
|
|
|
return new UrlProvider(
|
|
|
|
|
|
new TestUmbracoContextAccessor(umbracoContext),
|
|
|
|
|
|
Microsoft.Extensions.Options.Options.Create(webRoutingSettings),
|
|
|
|
|
|
new UrlProviderCollection(new[] { urlProvider }),
|
|
|
|
|
|
new MediaUrlProviderCollection(Enumerable.Empty<IMediaUrlProvider>()),
|
|
|
|
|
|
Mock.Of<IVariationContextAccessor>());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|