2020-12-19 08:17:35 +01:00
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
2021-02-18 11:06:02 +01:00
|
|
|
using Umbraco.Cms.Core.Web;
|
2016-11-07 19:12:09 +01:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
namespace Umbraco.Cms.Tests.Common;
|
2018-06-28 23:28:22 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public class TestUmbracoContextAccessor : IUmbracoContextAccessor
|
|
|
|
|
{
|
|
|
|
|
private IUmbracoContext _umbracoContext;
|
2018-06-28 23:28:22 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public TestUmbracoContextAccessor()
|
|
|
|
|
{
|
|
|
|
|
}
|
2021-08-11 11:06:55 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public TestUmbracoContextAccessor(IUmbracoContext umbracoContext) => _umbracoContext = umbracoContext;
|
2021-08-11 11:33:46 +02:00
|
|
|
|
2022-06-21 08:09:38 +02:00
|
|
|
public bool TryGetUmbracoContext(out IUmbracoContext umbracoContext)
|
|
|
|
|
{
|
|
|
|
|
umbracoContext = _umbracoContext;
|
|
|
|
|
return umbracoContext is not null;
|
2016-11-07 19:12:09 +01:00
|
|
|
}
|
2022-06-21 08:09:38 +02:00
|
|
|
|
|
|
|
|
public void Clear() => _umbracoContext = null;
|
|
|
|
|
public void Set(IUmbracoContext umbracoContext) => _umbracoContext = umbracoContext;
|
2017-07-20 11:21:28 +02:00
|
|
|
}
|