Make PublishedContentQueryAccessor usable (#11601)
* Make PublishedContentQueryAccessor usable Closes #11319 * Make xmldocs for IPublishedContentQueryAccessor more helpful.
This commit is contained in:
committed by
Bjarke Berg
parent
32d8e0bb96
commit
f64894d37b
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Cms.Core;
|
||||
using Umbraco.Cms.Tests.Integration.TestServerTest;
|
||||
|
||||
namespace Umbraco.Cms.Tests.Integration.Umbraco.Core
|
||||
{
|
||||
[TestFixture]
|
||||
public class PublishedContentQueryAccessorTests : UmbracoTestServerTestBase
|
||||
{
|
||||
[Test]
|
||||
public async Task PublishedContentQueryAccessor_WithRequestScope_WillProvideQuery()
|
||||
{
|
||||
HttpResponseMessage result = await Client.GetAsync("/demo-published-content-query-accessor");
|
||||
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
|
||||
}
|
||||
}
|
||||
|
||||
public class PublishedContentQueryAccessorTestController : Controller
|
||||
{
|
||||
private readonly IPublishedContentQueryAccessor _accessor;
|
||||
|
||||
public PublishedContentQueryAccessorTestController(IPublishedContentQueryAccessor accessor)
|
||||
{
|
||||
_accessor = accessor;
|
||||
}
|
||||
|
||||
[HttpGet("demo-published-content-query-accessor")]
|
||||
public IActionResult Test()
|
||||
{
|
||||
var success = _accessor.TryGetValue(out IPublishedContentQuery query);
|
||||
|
||||
if (!success || query == null)
|
||||
{
|
||||
throw new ApplicationException("It doesn't work");
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user