Skip to content

Instantly share code, notes, and snippets.

@StefanoChiodino
Last active March 19, 2018 12:21
Show Gist options
  • Save StefanoChiodino/6487812738c32a3d6897deaa9b287ba5 to your computer and use it in GitHub Desktop.
Save StefanoChiodino/6487812738c32a3d6897deaa9b287ba5 to your computer and use it in GitHub Desktop.
private UmbracoContext GetUmbracoContext()
{
var httpContextbaseMock = new Mock<HttpContextBase>();
var applicationContext = GetAppicationContext();
var webSecurity = new WebSecurity(httpContextbaseMock.Object, applicationContext);
var umbracoSettingsSectionMock = new Mock<IUmbracoSettingsSection>();
var umbracoContext = UmbracoContext.EnsureContext(httpContextbaseMock.Object,
applicationContext, webSecurity, umbracoSettingsSectionMock.Object,
Enumerable.Empty<IUrlProvider>(), true);
return umbracoContext;
}
private static ApplicationContext GetAppicationContext()
{
var cacheHelperMock = new Mock<CacheHelper>();
var loggermock = new Mock<ILogger>();
var profilingLogger = new ProfilingLogger(loggermock.Object, new Mock<IProfiler>().Object);
var serviceContextMock = new Mock<ServiceContext>(null, null, null, null, null, null,
null,
null, null, null, null, new Mock<IMemberService>().Object, new Mock<IUserService>().Object, null, null,
null, null, null, null,
null, null, null, null, null,
null, null);
var databaseFactory2Mock = new Mock<IDatabaseFactory2>();
var databaseContext = new DatabaseContext(databaseFactory2Mock.Object, loggermock.Object,
new SqlSyntaxProviders(new List<ISqlSyntaxProvider>()));
var applicationContext = ApplicationContext.EnsureContext(databaseContext, serviceContextMock.Object,
cacheHelperMock.Object, profilingLogger, true);
return applicationContext;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment