Start working on tests
This commit is contained in:
38
src/Umbraco.Tests.Integration/FileNames/UiFileNames.cs
Normal file
38
src/Umbraco.Tests.Integration/FileNames/UiFileNames.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Umbraco.Tests.Integration.FileNames
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class UiFileNames
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void MacroTemplates()
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(@"..\\..\\..\\..\\Umbraco.Web.UI.NetCore\\umbraco\\PartialViewMacros\\Templates");
|
||||||
|
foreach(var file in files)
|
||||||
|
{
|
||||||
|
var fileName = file.Split("\\").Last();
|
||||||
|
Assert.AreEqual(char.ToUpper(fileName[0]), fileName[0], $"{fileName} does not start with an uppercase letter.");
|
||||||
|
var titleCase = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(fileName.ToLower());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void LanguageFilesAreLowercase()
|
||||||
|
{
|
||||||
|
var files = Directory.GetFiles(@"..\\..\\..\\..\\Umbraco.Web.UI.NetCore\\umbraco\\config\\lang");
|
||||||
|
foreach(var file in files)
|
||||||
|
{
|
||||||
|
var fileName = file.Split("\\").Last();
|
||||||
|
Assert.AreEqual(fileName.ToLower(), fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@ using Moq;
|
|||||||
using Umbraco.Core.BackOffice;
|
using Umbraco.Core.BackOffice;
|
||||||
using Umbraco.Core.Configuration;
|
using Umbraco.Core.Configuration;
|
||||||
using Umbraco.Web.BackOffice.Controllers;
|
using Umbraco.Web.BackOffice.Controllers;
|
||||||
|
using Umbraco.Core;
|
||||||
|
using Umbraco.Web.Common.Install;
|
||||||
|
|
||||||
namespace Umbraco.Tests.UnitTests.AutoFixture
|
namespace Umbraco.Tests.UnitTests.AutoFixture
|
||||||
{
|
{
|
||||||
@@ -36,12 +38,24 @@ namespace Umbraco.Tests.UnitTests.AutoFixture
|
|||||||
(a,b,c) => BackOfficeIdentityUser.CreateNew(Mock.Of<IGlobalSettings>(),a,b,c)));
|
(a,b,c) => BackOfficeIdentityUser.CreateNew(Mock.Of<IGlobalSettings>(),a,b,c)));
|
||||||
fixture
|
fixture
|
||||||
.Customize(new ConstructorCustomization(typeof(UsersController), new GreedyConstructorQuery()))
|
.Customize(new ConstructorCustomization(typeof(UsersController), new GreedyConstructorQuery()))
|
||||||
|
.Customize(new ConstructorCustomization(typeof(InstallController), new GreedyConstructorQuery()))
|
||||||
.Customize(new ConstructorCustomization(typeof(BackOfficeUserManager), new GreedyConstructorQuery()))
|
.Customize(new ConstructorCustomization(typeof(BackOfficeUserManager), new GreedyConstructorQuery()))
|
||||||
.Customize(new AutoMoqCustomization());
|
.Customize(new AutoMoqCustomization());
|
||||||
|
|
||||||
// When requesting an IUserStore ensure we actually uses a IUserLockoutStore
|
// When requesting an IUserStore ensure we actually uses a IUserLockoutStore
|
||||||
fixture.Customize<IUserStore<BackOfficeIdentityUser>>(cc => cc.FromFactory(() => Mock.Of<IUserLockoutStore<BackOfficeIdentityUser>>()));
|
fixture.Customize<IUserStore<BackOfficeIdentityUser>>(cc => cc.FromFactory(() => Mock.Of<IUserLockoutStore<BackOfficeIdentityUser>>()));
|
||||||
|
|
||||||
|
fixture.Customize<ConfigConnectionString>(
|
||||||
|
u => u.FromFactory<string, string, string>(
|
||||||
|
(a, b, c) => new ConfigConnectionString(a, b, c)));
|
||||||
|
|
||||||
|
fixture.Customize<IUmbracoVersion>(
|
||||||
|
u => u.FromFactory(
|
||||||
|
() => new UmbracoVersion()));
|
||||||
|
|
||||||
|
var connectionStrings = Mock.Of<IConnectionStrings>();
|
||||||
|
Mock.Get(connectionStrings).Setup(x => x[Constants.System.UmbracoConnectionName]).Returns((ConfigConnectionString)new ConfigConnectionString(string.Empty, string.Empty, string.Empty));
|
||||||
|
fixture.Customize<IConnectionStrings>(x => x.FromFactory(() => connectionStrings ));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,16 @@ namespace Umbraco.Extensions
|
|||||||
return linkGenerator.GetPathByAction(nameof(InstallController.Index), ControllerExtensions.GetControllerName<InstallController>(), new { area = Constants.Web.Mvc.InstallArea });
|
return linkGenerator.GetPathByAction(nameof(InstallController.Index), ControllerExtensions.GetControllerName<InstallController>(), new { area = Constants.Web.Mvc.InstallArea });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the URL for the installer api
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="linkGenerator"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetInstallerApiUrl(this LinkGenerator linkGenerator)
|
||||||
|
{
|
||||||
|
return linkGenerator.GetPathByAction(nameof(InstallController.Index), ControllerExtensions.GetControllerName<InstallApiController>(), new { area = Constants.Web.Mvc.InstallArea });
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the Url for a Web Api service
|
/// Return the Url for a Web Api service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -32,18 +32,6 @@ namespace Umbraco.Extensions
|
|||||||
return url.Action("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeApiArea });
|
return url.Action("Default", ControllerExtensions.GetControllerName(backOfficeControllerType), new { area = Constants.Web.Mvc.BackOfficeApiArea });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return the installer API url
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="url"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetInstallerApiUrl(this IUrlHelper url)
|
|
||||||
{
|
|
||||||
// there is no default action here so we need to get it by action and trim the action
|
|
||||||
return url.Action("GetSetup", ControllerExtensions.GetControllerName<InstallApiController>(), new { area = Constants.Web.Mvc.InstallArea })
|
|
||||||
.TrimEnd("GetSetup");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return the Url for a Web Api service
|
/// Return the Url for a Web Api service
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ namespace Umbraco.Web.Common.Install
|
|||||||
}
|
}
|
||||||
|
|
||||||
// gen the install base url
|
// gen the install base url
|
||||||
ViewData.SetInstallApiBaseUrl(Url.GetInstallerApiUrl());
|
ViewData.SetInstallApiBaseUrl(_linkGenerator.GetInstallerApiUrl());
|
||||||
|
|
||||||
// get the base umbraco folder
|
// get the base umbraco folder
|
||||||
var baseFolder = _hostingEnvironment.ToAbsolute(_globalSettings.UmbracoPath);
|
var baseFolder = _hostingEnvironment.ToAbsolute(_globalSettings.UmbracoPath);
|
||||||
|
|||||||
Reference in New Issue
Block a user