This commit is contained in:
Stephan
2017-09-23 10:08:18 +02:00
parent c1e2625de0
commit 5ba2ffcbf3
224 changed files with 709 additions and 709 deletions

View File

@@ -1,4 +1,4 @@
using System;
using System;
using Microsoft.Owin.Extensions;
using Owin;
@@ -15,4 +15,4 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
return app;
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Microsoft.Owin.Security;
@@ -31,7 +31,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
Roles = new[] { "admin" },
AllowedApplications = new[] { "content", "media", "members" },
Culture = "en-US",
RealName = "Admin",
RealName = "Admin",
Username = "admin"
});
@@ -52,4 +52,4 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
}
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Reflection;
using System.Web.Http.Dispatcher;
@@ -18,4 +18,4 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
return _assemblies;
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Web.Http;
using Umbraco.Web;
@@ -12,11 +12,11 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
public TestControllerActivator(Func<HttpRequestMessage, UmbracoHelper, ApiController> factory)
{
_factory = factory;
}
}
protected override ApiController CreateController(Type controllerType, HttpRequestMessage msg, UmbracoHelper helper)
{
return _factory(msg, helper);
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -46,7 +46,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
return base.Create(request, controllerDescriptor, controllerType);
var owinContext = request.TryGetOwinContext().Result;
var mockedUserService = Mock.Of<IUserService>();
var mockedContentService = Mock.Of<IContentService>();
var mockedMediaService = Mock.Of<IMediaService>();
@@ -85,12 +85,12 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
//httpcontext with an auth'd user
var httpContext = Mock.Of<HttpContextBase>(
http => http.User == owinContext.Authentication.User
//ensure the request exists with a cookies collection
//ensure the request exists with a cookies collection
&& http.Request == Mock.Of<HttpRequestBase>(r => r.Cookies == new HttpCookieCollection())
//ensure the request exists with an items collection
//ensure the request exists with an items collection
&& http.Items == Mock.Of<IDictionary>());
//chuck it into the props since this is what MS does when hosted and it's needed there
request.Properties["MS_HttpContext"] = httpContext;
request.Properties["MS_HttpContext"] = httpContext;
var backofficeIdentity = (UmbracoBackOfficeIdentity) owinContext.Authentication.User.Identity;
@@ -118,7 +118,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
//mock Validate
webSecurity.Setup(x => x.ValidateCurrentUser())
.Returns(() => true);
.Returns(() => true);
webSecurity.Setup(x => x.UserHasSectionAccess(It.IsAny<string>(), It.IsAny<IUser>()))
.Returns(() => true);
@@ -140,7 +140,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
Mock.Of<IUmbracoSettingsSection>(section => section.WebRouting == Mock.Of<IWebRoutingSection>(routingSection => routingSection.UrlProviderMode == UrlProviderMode.Auto.ToString())),
Enumerable.Empty<IUrlProvider>(),
true); //replace it
var urlHelper = new Mock<IUrlProvider>();
urlHelper.Setup(provider => provider.GetUrl(It.IsAny<UmbracoContext>(), It.IsAny<int>(), It.IsAny<Uri>(), It.IsAny<UrlProviderMode>()))
.Returns("/hello/world/1234");
@@ -165,4 +165,4 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
protected abstract ApiController CreateController(Type controllerType, HttpRequestMessage msg, UmbracoHelper helper);
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
@@ -76,4 +76,4 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
Console.Out.WriteLine(result);
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.Dispatcher;
@@ -26,7 +26,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
}
public void Configuration(IAppBuilder app)
{
{
var httpConfig = new HttpConfiguration();
//TODO: Enable this if you can't see the errors produced
@@ -42,13 +42,13 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
httpConfig.Services.Replace(typeof (IAssembliesResolver), new SpecificAssemblyResolver(new[] { typeof (UsersController).Assembly }));
httpConfig.Services.Replace(typeof (IHttpControllerActivator), new TestControllerActivator(_controllerFactory));
httpConfig.Services.Replace(typeof (IHttpControllerSelector), new NamespaceHttpControllerSelector(httpConfig));
//auth everything
app.AuthenticateEverything();
app.AuthenticateEverything();
_initialize(httpConfig);
app.UseWebApi(httpConfig);
}
}
}
}

View File

@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using System.Web.Http.ExceptionHandling;
namespace Umbraco.Tests.TestHelpers.ControllerTesting
@@ -13,4 +13,4 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
Trace.TraceError(context.ExceptionContext.Exception.ToString());
}
}
}
}