Performance: Cache published content instances at cache service level (#20681)
Cache published content instances at cache service level
This commit is contained in:
@@ -85,17 +85,50 @@ internal sealed class DocumentHybridCacheTests : UmbracoIntegrationTestWithConte
|
||||
Assert.IsFalse(textPage.IsPublished());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task Cannot_get_unpublished_content()
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public async Task Can_Get_Unpublished_Content_By_Key(bool preview)
|
||||
{
|
||||
// Arrange
|
||||
var unpublishAttempt = await ContentPublishingService.UnpublishAsync(PublishedTextPage.Key.Value, null, Constants.Security.SuperUserKey);
|
||||
Assert.IsTrue(unpublishAttempt.Success);
|
||||
|
||||
//Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, false);
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPage.Key.Value, preview);
|
||||
|
||||
// Assert
|
||||
Assert.IsNull(textPage);
|
||||
if (preview)
|
||||
{
|
||||
Assert.IsNotNull(textPage);
|
||||
Assert.IsFalse(textPage.IsPublished());
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNull(textPage);
|
||||
}
|
||||
}
|
||||
|
||||
[TestCase(true)]
|
||||
[TestCase(false)]
|
||||
public async Task Can_Get_Unpublished_Content_By_Id(bool preview)
|
||||
{
|
||||
// Arrange
|
||||
var unpublishAttempt = await ContentPublishingService.UnpublishAsync(PublishedTextPage.Key.Value, null, Constants.Security.SuperUserKey);
|
||||
Assert.IsTrue(unpublishAttempt.Success);
|
||||
|
||||
// Act
|
||||
var textPage = await PublishedContentHybridCache.GetByIdAsync(PublishedTextPageId, preview);
|
||||
|
||||
// Assert
|
||||
if (preview)
|
||||
{
|
||||
Assert.IsNotNull(textPage);
|
||||
Assert.IsFalse(textPage.IsPublished());
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert.IsNull(textPage);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in New Issue
Block a user