Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a solution for https://github.com/umbraco/Umbraco-CMS/issues/11074, but I would like to write a test for it. The issue I am having is figuring out how to test the Url based on the content cache. I am looking at Umbraco.Tests/Published/PropertyCacheLevelTests.cs as an example, but I'm not sure that is the right place. None of the service providers seem to give access to IPublishedContent or UrlProvder.
I am still digging, but thought I might get a quicker answer here
I am instead looking at \Umbraco.Tests\PublishedContent\NuCacheTests.cs, which seems to be much more analogous to what I am trying to do.
However, when the snapshot service creates a snapshot, the publishedContent.Name is null, when I would expect it to be It Works1!. Clearly I am missing something.
The underlying publishedcontent.ContentData.Name is the value I expect publishedContent.Name to be.
OK, I got beyond this. I needed to create content that did not have a culture variant.
Now I am trying to figure out how to simulate a cache rebuild. Because the test does not use a database, using _snapshotService.Rebuild() has null references.
Addendum, I actually just needed to do
_contentType.Variations = ContentVariation.Nothing;
_propertyType.Variations = ContentVariation.Nothing;
before creating the snapshot, rather than creating a separate init(). I still have the problem of testing rebuild()
I am going to stop posting every 20 minutes on this. I may submit a PR with the change and see what happens. This really feels like something that should have a test, but the change is in \Umbraco.Web\PublishedCache\NuCache\PublishedSnapshotService.cs#GetDto. This is a private method that is only called from methods that make calls to the database. I am not aware of a way to perform that test, but if there is a way, I would love to learn how to write it.
I came across TestWithDatabaseBase and I am looking at that.
I seem to have gotten what I was looking for! I will try to remember to come back here and link my commit when it goes in.
And once I got the test working.. I discovered a failure I didn't account for!
The commit that contains the code I used for using an actual database for testing: https://github.com/umbraco/Umbraco-CMS/pull/11313/commits/d309f118d1e827dc2247cc9c8d6ffd0d285161c1
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted