diff --git a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
index eb5d4bca3d..2434b2b8fb 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
+++ b/src/Umbraco.Tests.Integration/TestServerTest/UmbracoTestServerTestBase.cs
@@ -19,7 +19,6 @@ using Umbraco.Core.Cache;
using Umbraco.Core.Composing;
using Umbraco.Core.DependencyInjection;
using Umbraco.Extensions;
-using Umbraco.Infrastructure.PublishedCache.DependencyInjection;
using Umbraco.Tests.Integration.DependencyInjection;
using Umbraco.Tests.Integration.Testing;
using Umbraco.Tests.Testing;
@@ -84,11 +83,32 @@ namespace Umbraco.Tests.Integration.TestServerTest
/// This returns the url but also sets the HttpContext.request into to use this url.
///
/// The string URL of the controller action.
- protected string PrepareUrl(Expression> methodSelector)
+ protected string PrepareApiControllerUrl(Expression> methodSelector)
where T : UmbracoApiController
{
- string url = LinkGenerator.GetUmbracoApiService(methodSelector);
+ string url = LinkGenerator.GetUmbracoApiService(methodSelector);
+ return PrepareUrl(url);
+ }
+ ///
+ /// Prepare a url before using .
+ /// This returns the url but also sets the HttpContext.request into to use this url.
+ ///
+ /// The string URL of the controller action.
+ protected string PrepareSurfaceControllerUrl(Expression> methodSelector)
+ where T : SurfaceController
+ {
+ string url = LinkGenerator.GetUmbracoSurfaceUrl(methodSelector);
+ return PrepareUrl(url);
+ }
+
+ ///
+ /// Prepare a url before using .
+ /// This returns the url but also sets the HttpContext.request into to use this url.
+ ///
+ /// The string URL of the controller action.
+ protected string PrepareUrl(string url)
+ {
IBackOfficeSecurityFactory backofficeSecurityFactory = GetRequiredService();
IUmbracoContextFactory umbracoContextFactory = GetRequiredService();
IHttpContextAccessor httpContextAccessor = GetRequiredService();
@@ -150,6 +170,9 @@ namespace Umbraco.Tests.Integration.TestServerTest
// Adds Umbraco.Web.Website
mvcBuilder.AddApplicationPart(typeof(SurfaceController).Assembly);
+
+ // Adds Umbraco.Tests.Integration
+ mvcBuilder.AddApplicationPart(typeof(UmbracoTestServerTestBase).Assembly);
})
.AddWebServer()
.AddWebsite()
diff --git a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/BackOfficeAssetsControllerTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/BackOfficeAssetsControllerTests.cs
similarity index 72%
rename from src/Umbraco.Tests.Integration/TestServerTest/Controllers/BackOfficeAssetsControllerTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/BackOfficeAssetsControllerTests.cs
index f519d939b8..9304f005b3 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/BackOfficeAssetsControllerTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/BackOfficeAssetsControllerTests.cs
@@ -5,9 +5,10 @@ using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using NUnit.Framework;
+using Umbraco.Tests.Integration.TestServerTest;
using Umbraco.Web.BackOffice.Controllers;
-namespace Umbraco.Tests.Integration.TestServerTest.Controllers
+namespace Umbraco.Tests.Integration.Umbraco.Web.BackOffice.Controllers
{
[TestFixture]
public class BackOfficeAssetsControllerTests : UmbracoTestServerTestBase
@@ -16,7 +17,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
public async Task EnsureSuccessStatusCode()
{
// Arrange
- string url = PrepareUrl(x => x.GetSupportedLocales());
+ string url = PrepareApiControllerUrl(x => x.GetSupportedLocales());
// Act
HttpResponseMessage response = await Client.GetAsync(url);
diff --git a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs
similarity index 95%
rename from src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs
index cd7095ba75..a353cbdc7f 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/ContentControllerTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/ContentControllerTests.cs
@@ -12,11 +12,12 @@ using Umbraco.Core.Models;
using Umbraco.Core.Services;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
+using Umbraco.Tests.Integration.TestServerTest;
using Umbraco.Web.BackOffice.Controllers;
using Umbraco.Web.Common.Formatters;
using Umbraco.Web.Models.ContentEditing;
-namespace Umbraco.Tests.Integration.TestServerTest.Controllers
+namespace Umbraco.Tests.Integration.Umbraco.Web.BackOffice.Controllers
{
[TestFixture]
public class ContentControllerTests : UmbracoTestServerTestBase
@@ -35,7 +36,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.WithIsDefault(false)
.Build());
- string url = PrepareUrl(x => x.PostSave(null));
+ string url = PrepareApiControllerUrl(x => x.PostSave(null));
IContentService contentService = GetRequiredService();
IContentTypeService contentTypeService = GetRequiredService();
@@ -93,7 +94,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.WithIsDefault(false)
.Build());
- string url = PrepareUrl(x => x.PostSave(null));
+ string url = PrepareApiControllerUrl(x => x.PostSave(null));
IContentTypeService contentTypeService = GetRequiredService();
@@ -162,7 +163,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.WithIsDefault(false)
.Build());
- string url = PrepareUrl(x => x.PostSave(null));
+ string url = PrepareApiControllerUrl(x => x.PostSave(null));
IContentService contentService = GetRequiredService();
IContentTypeService contentTypeService = GetRequiredService();
@@ -227,7 +228,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.WithIsDefault(false)
.Build());
- string url = PrepareUrl(x => x.PostSave(null));
+ string url = PrepareApiControllerUrl(x => x.PostSave(null));
IContentService contentService = GetRequiredService();
IContentTypeService contentTypeService = GetRequiredService();
@@ -288,7 +289,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.WithIsDefault(false)
.Build());
- string url = PrepareUrl(x => x.PostSave(null));
+ string url = PrepareApiControllerUrl(x => x.PostSave(null));
IContentService contentService = GetRequiredService();
IContentTypeService contentTypeService = GetRequiredService();
@@ -352,7 +353,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.WithIsDefault(false)
.Build());
- string url = PrepareUrl(x => x.PostSave(null));
+ string url = PrepareApiControllerUrl(x => x.PostSave(null));
IContentService contentService = GetRequiredService();
IContentTypeService contentTypeService = GetRequiredService();
diff --git a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/TemplateQueryControllerTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/TemplateQueryControllerTests.cs
similarity index 88%
rename from src/Umbraco.Tests.Integration/TestServerTest/Controllers/TemplateQueryControllerTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/TemplateQueryControllerTests.cs
index 8a558c53d4..10478f1078 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/TemplateQueryControllerTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/TemplateQueryControllerTests.cs
@@ -11,12 +11,13 @@ using Newtonsoft.Json.Linq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Tests.Common.Builders.Extensions;
+using Umbraco.Tests.Integration.TestServerTest;
using Umbraco.Tests.Testing;
using Umbraco.Web.BackOffice.Controllers;
using Umbraco.Web.Common.Formatters;
using Umbraco.Web.Models.TemplateQuery;
-namespace Umbraco.Tests.Integration.TestServerTest.Controllers
+namespace Umbraco.Tests.Integration.Umbraco.Web.BackOffice.Controllers
{
[TestFixture]
public class TemplateQueryControllerTests : UmbracoTestServerTestBase
@@ -24,7 +25,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
[Test]
public async Task GetContentTypes__Ensure_camel_case()
{
- string url = PrepareUrl(x => x.GetContentTypes());
+ string url = PrepareApiControllerUrl(x => x.GetContentTypes());
// Act
HttpResponseMessage response = await Client.GetAsync(url);
diff --git a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/UsersControllerTests.cs b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/UsersControllerTests.cs
similarity index 90%
rename from src/Umbraco.Tests.Integration/TestServerTest/Controllers/UsersControllerTests.cs
rename to src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/UsersControllerTests.cs
index fbba385cdc..4814d158af 100644
--- a/src/Umbraco.Tests.Integration/TestServerTest/Controllers/UsersControllerTests.cs
+++ b/src/Umbraco.Tests.Integration/Umbraco.Web.BackOffice/Controllers/UsersControllerTests.cs
@@ -17,13 +17,14 @@ using Umbraco.Core.Models.Membership;
using Umbraco.Core.Services;
using Umbraco.Tests.Common.Builders;
using Umbraco.Tests.Common.Builders.Extensions;
+using Umbraco.Tests.Integration.TestServerTest;
using Umbraco.Tests.Testing;
using Umbraco.Web.BackOffice.Controllers;
using Umbraco.Web.Common.Filters;
using Umbraco.Web.Common.Formatters;
using Umbraco.Web.Models.ContentEditing;
-namespace Umbraco.Tests.Integration.TestServerTest.Controllers
+namespace Umbraco.Tests.Integration.Umbraco.Web.BackOffice.Controllers
{
[TestFixture]
public class UsersControllerTests : UmbracoTestServerTestBase
@@ -31,7 +32,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
[Test]
public async Task Save_User()
{
- string url = PrepareUrl(x => x.PostSaveUser(null));
+ string url = PrepareApiControllerUrl(x => x.PostSaveUser(null));
IUserService userService = GetRequiredService();
@@ -81,7 +82,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
public async Task GetPagedUsers_Empty()
{
// We get page 2 to force an empty response because there always in the useradmin user
- string url = PrepareUrl(x => x.GetPagedUsers(2, 10, "username", Direction.Ascending, null, null, string.Empty));
+ string url = PrepareApiControllerUrl(x => x.GetPagedUsers(2, 10, "username", Direction.Ascending, null, null, string.Empty));
// Act
HttpResponseMessage response = await Client.GetAsync(url);
@@ -106,7 +107,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
{
int totalNumberOfUsers = 11;
int pageSize = totalNumberOfUsers - 1;
- string url = PrepareUrl(x => x.GetPagedUsers(1, pageSize, "username", Direction.Ascending, null, null, string.Empty));
+ string url = PrepareApiControllerUrl(x => x.GetPagedUsers(1, pageSize, "username", Direction.Ascending, null, null, string.Empty));
IUserService userService = GetRequiredService();
@@ -144,7 +145,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
[Test]
public async Task PostUnlockUsers_When_UserIds_Not_Supplied_Expect_Ok_Response()
{
- string url = PrepareUrl(x => x.PostUnlockUsers(Array.Empty()));
+ string url = PrepareApiControllerUrl(x => x.PostUnlockUsers(Array.Empty()));
// Act
HttpResponseMessage response = await Client.PostAsync(url, new StringContent(string.Empty));
@@ -156,7 +157,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
public async Task PostUnlockUsers_When_User_Does_Not_Exist_Expect_Zero_Users_Message()
{
int userId = 42; // Must not exist
- string url = PrepareUrl(x => x.PostUnlockUsers(new[] { userId }));
+ string url = PrepareApiControllerUrl(x => x.PostUnlockUsers(new[] { userId }));
// Act
HttpResponseMessage response = await Client.PostAsync(url, new StringContent(string.Empty));
@@ -184,7 +185,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
.Build();
userService.Save(user);
- string url = PrepareUrl(x => x.PostUnlockUsers(new[] { user.Id }));
+ string url = PrepareApiControllerUrl(x => x.PostUnlockUsers(new[] { user.Id }));
// Act
HttpResponseMessage response = await Client.PostAsync(url, new StringContent(string.Empty));
@@ -228,7 +229,7 @@ namespace Umbraco.Tests.Integration.TestServerTest.Controllers
userService.Save(user);
}
- string url = PrepareUrl(x => x.PostUnlockUsers(users.Select(x => x.Id).ToArray()));
+ string url = PrepareApiControllerUrl(x => x.PostUnlockUsers(users.Select(x => x.Id).ToArray()));
// Act
HttpResponseMessage response = await Client.PostAsync(url, new StringContent(string.Empty));