* 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>
52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
// Copyright (c) Umbraco.
|
|
// See LICENSE for more details.
|
|
|
|
using System;
|
|
using System.Threading.Tasks;
|
|
using NUnit.Framework;
|
|
using Umbraco.Cms.Core.Strings;
|
|
using Umbraco.Cms.Tests.UnitTests.AutoFixture;
|
|
using Umbraco.Cms.Web.Common.AspNetCore;
|
|
|
|
namespace Umbraco.Cms.Tests.UnitTests.Umbraco.Web.Website
|
|
{
|
|
[TestFixture]
|
|
public class AspNetCoreHostingEnvironmentTests
|
|
{
|
|
[InlineAutoMoqData("~/Scripts", "/Scripts", null)]
|
|
[InlineAutoMoqData("/Scripts", "/Scripts", null)]
|
|
[InlineAutoMoqData("../Scripts", "/Scripts", typeof(InvalidOperationException))]
|
|
public void IOHelper_ResolveUrl(string input, string expected, Type expectedExceptionType, AspNetCoreHostingEnvironment sut)
|
|
{
|
|
if (expectedExceptionType != null)
|
|
{
|
|
Assert.Throws(expectedExceptionType, () => sut.ToAbsolute(input));
|
|
}
|
|
else
|
|
{
|
|
var result = sut.ToAbsolute(input);
|
|
Assert.AreEqual(expected, result);
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void EnsurePathIsApplicationRootPrefixed()
|
|
{
|
|
// Assert
|
|
Assert.AreEqual("~/Views/Template.cshtml", PathUtility.EnsurePathIsApplicationRootPrefixed("Views/Template.cshtml"));
|
|
Assert.AreEqual("~/Views/Template.cshtml", PathUtility.EnsurePathIsApplicationRootPrefixed("/Views/Template.cshtml"));
|
|
Assert.AreEqual("~/Views/Template.cshtml", PathUtility.EnsurePathIsApplicationRootPrefixed("~/Views/Template.cshtml"));
|
|
}
|
|
|
|
[AutoMoqData]
|
|
[Test]
|
|
public void EnsureApplicationMainUrl(AspNetCoreHostingEnvironment sut)
|
|
{
|
|
var url = new Uri("http://localhost:5000");
|
|
sut.EnsureApplicationMainUrl(url);
|
|
Assert.AreEqual(sut.ApplicationMainUrl, url);
|
|
|
|
}
|
|
}
|
|
}
|