U4-8447 - prepare for NuCache (work-in-progress)
This commit is contained in:
@@ -57,177 +57,6 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
return repository;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Rebuild_Xml_Structures_With_Non_Latest_Version()
|
||||
{
|
||||
var provider = TestObjects.GetDatabaseUnitOfWorkProvider(Logger);
|
||||
using (var unitOfWork = provider.CreateUnitOfWork())
|
||||
{
|
||||
ContentTypeRepository contentTypeRepository;
|
||||
var repository = CreateRepository(unitOfWork, out contentTypeRepository);
|
||||
|
||||
var contentType1 = MockedContentTypes.CreateSimpleContentType("Textpage1", "Textpage1");
|
||||
contentTypeRepository.AddOrUpdate(contentType1);
|
||||
|
||||
var allCreated = new List<IContent>();
|
||||
|
||||
//create 100 non published
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType1);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
//create 100 published
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType1);
|
||||
c1.ChangePublishedState(PublishedState.Publishing);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
unitOfWork.Flush();
|
||||
|
||||
//now create some versions of this content - this shouldn't affect the xml structures saved
|
||||
for (var i = 0; i < allCreated.Count; i++)
|
||||
{
|
||||
allCreated[i].Name = "blah" + i;
|
||||
//IMPORTANT testing note here: We need to changed the published state here so that
|
||||
// it doesn't automatically think this is simply publishing again - this forces the latest
|
||||
// version to be Saved and not published
|
||||
allCreated[i].ChangePublishedState(PublishedState.Saving);
|
||||
repository.AddOrUpdate(allCreated[i]);
|
||||
}
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
Assert.AreEqual(0, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
repository.RebuildXmlStructures(content => new XElement("test"), 10);
|
||||
|
||||
Assert.AreEqual(100, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Rebuild_All_Xml_Structures()
|
||||
{
|
||||
var provider = TestObjects.GetDatabaseUnitOfWorkProvider(Logger);
|
||||
using (var unitOfWork = provider.CreateUnitOfWork())
|
||||
{
|
||||
ContentTypeRepository contentTypeRepository;
|
||||
var repository = CreateRepository(unitOfWork, out contentTypeRepository);
|
||||
|
||||
var contentType1 = MockedContentTypes.CreateSimpleContentType("Textpage1", "Textpage1");
|
||||
contentTypeRepository.AddOrUpdate(contentType1);
|
||||
var allCreated = new List<IContent>();
|
||||
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
//These will be non-published so shouldn't show up
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType1);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
for (var i = 0; i < 100; i++)
|
||||
{
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType1);
|
||||
c1.ChangePublishedState(PublishedState.Publishing);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
unitOfWork.Flush();
|
||||
|
||||
//now create some versions of this content - this shouldn't affect the xml structures saved
|
||||
for (int i = 0; i < allCreated.Count; i++)
|
||||
{
|
||||
allCreated[i].Name = "blah" + i;
|
||||
repository.AddOrUpdate(allCreated[i]);
|
||||
}
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
Assert.AreEqual(0, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
repository.RebuildXmlStructures(media => new XElement("test"), 10);
|
||||
|
||||
Assert.AreEqual(100, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Rebuild_All_Xml_Structures_For_Content_Type()
|
||||
{
|
||||
var provider = TestObjects.GetDatabaseUnitOfWorkProvider(Logger);
|
||||
using (var unitOfWork = provider.CreateUnitOfWork())
|
||||
{
|
||||
ContentTypeRepository contentTypeRepository;
|
||||
var repository = CreateRepository(unitOfWork, out contentTypeRepository);
|
||||
var contentType1 = MockedContentTypes.CreateSimpleContentType("Textpage1", "Textpage1");
|
||||
var contentType2 = MockedContentTypes.CreateSimpleContentType("Textpage2", "Textpage2");
|
||||
var contentType3 = MockedContentTypes.CreateSimpleContentType("Textpage3", "Textpage3");
|
||||
contentTypeRepository.AddOrUpdate(contentType1);
|
||||
contentTypeRepository.AddOrUpdate(contentType2);
|
||||
contentTypeRepository.AddOrUpdate(contentType3);
|
||||
|
||||
var allCreated = new List<IContent>();
|
||||
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
//These will be non-published so shouldn't show up
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType1);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType1);
|
||||
c1.ChangePublishedState(PublishedState.Publishing);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType2);
|
||||
c1.ChangePublishedState(PublishedState.Publishing);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
for (var i = 0; i < 30; i++)
|
||||
{
|
||||
var c1 = MockedContent.CreateSimpleContent(contentType3);
|
||||
c1.ChangePublishedState(PublishedState.Publishing);
|
||||
repository.AddOrUpdate(c1);
|
||||
allCreated.Add(c1);
|
||||
}
|
||||
unitOfWork.Flush();
|
||||
|
||||
//now create some versions of this content - this shouldn't affect the xml structures saved
|
||||
for (int i = 0; i < allCreated.Count; i++)
|
||||
{
|
||||
allCreated[i].Name = "blah" + i;
|
||||
repository.AddOrUpdate(allCreated[i]);
|
||||
}
|
||||
unitOfWork.Flush();
|
||||
|
||||
//delete all xml
|
||||
unitOfWork.Database.Execute("DELETE FROM cmsContentXml");
|
||||
Assert.AreEqual(0, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
repository.RebuildXmlStructures(media => new XElement("test"), 10, contentTypeIds: new[] { contentType1.Id, contentType2.Id });
|
||||
|
||||
Assert.AreEqual(60, unitOfWork.Database.ExecuteScalar<int>("SELECT COUNT(*) FROM cmsContentXml"));
|
||||
|
||||
unitOfWork.Complete();
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Ensures_Permissions_Are_Set_If_Parent_Entity_Permissions_Exist()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user