Files
Umbraco-CMS/tests/Umbraco.Tests.UnitTests/Umbraco.Web.Common/FileNameTests.cs
Nikolaj Geisle 595ee242aa V14: Remove old backoffice project. (#15752)
* Move magical route to management api

* Move auth around

* Remove "New" cookies, as they are no longer needed

* Move all installer related

* Remove BackOfficeServerVariables.cs and trees

* Move webhooks to management api

* Remove remainting controllers

* Remove last services

* Move preview to management api

* Remove mroe extensions

* Remove tours

* Remove old Auth handlers

* Remove server variables entirely

* Remove old backoffice controller

* Remove controllers namespace entirely

* Move rest of preview

* move last services

* Move language file extension

* Remove old backoffice entirely (Backoffice and Web.UI projects)

* Clean up unused security classes

* Fix up installer route

* Remove obsolete tests

* Fix up DI in integration test

* Add missing property mapping

* Move core mapping into core

* Add composers to integration test

* remove identity

* Fix up DI

* Outcomment failing test :)

* Fix up remaining test

* Update mapper

* Remove the actual project files

* Remove backoffice cs proj

* Remove old backoffice from yml

* Run belissima before login

* Remove caching

* Refactor file paths

* Remove belle from static assets

* Dont refer to old project in templates

* update gitignore

* Add missing files

* Remove install view as its no longer used

* Fix up failing test

* Remove outcommented code

* Update submodule to latest

* fix build

---------

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
2024-02-27 12:40:30 +01:00

67 lines
2.1 KiB
C#

// Copyright (c) Umbraco.
// See LICENSE for more details.
using AutoFixture.NUnit3;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.FileProviders;
using Moq;
using NUnit.Framework;
using Umbraco.Cms.Api.Management.Controllers.Security;
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Hosting;
using Umbraco.Cms.Tests.UnitTests.AutoFixture;
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Common;
[TestFixture]
internal class FileNameTests
{
private string GetViewName(ViewResult viewResult, string separator = "/")
{
var sections = viewResult.ViewName.Split(separator);
return sections[^1];
}
private IEnumerable<string> GetUiFiles(IEnumerable<string> pathFromNetCore)
{
var root = TestContext.CurrentContext.TestDirectory.Split("tests")[0];
var pathToFiles = Path.Combine(root, "src", "Umbraco.Cms.StaticAssets");
foreach (var pathSection in pathFromNetCore)
{
pathToFiles = Path.Combine(pathToFiles, pathSection);
}
return new DirectoryInfo(pathToFiles).GetFiles().Select(f => f.Name).ToArray();
}
[Test]
[AutoMoqData]
public void BackOfficeDefaultExists(BackOfficeDefaultController sut)
{
var viewResult = sut.DefaultView();
var fileName = GetViewName(viewResult);
var views = GetUiFiles(new[] { "umbraco", "UmbracoBackOffice" });
Assert.True(views.Contains(fileName), $"Expected {fileName} to exist, but it didn't");
}
[Test]
public void LanguageFilesAreLowerCase()
{
var languageProvider = new EmbeddedFileProvider(
typeof(IAssemblyProvider).Assembly,
"Umbraco.Cms.Core.EmbeddedResources.Lang");
var files = languageProvider.GetDirectoryContents(string.Empty)
.Where(x => !x.IsDirectory && x.Name.EndsWith(".xml"))
.Select(x => x.Name);
foreach (var fileName in files)
{
Assert.AreEqual(
fileName.ToLower(),
fileName,
$"Language files must be all lowercase but {fileName} is not lowercase.");
}
}
}