Migrate PartialViewRepositoryTests and ScriptRepositoryTest
This commit is contained in:
@@ -1,37 +1,36 @@
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Persistence.Repositories.Implement;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
using System;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Repositories
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
|
||||
{
|
||||
[TestFixture]
|
||||
[UmbracoTest(WithApplication = true, Database = UmbracoTestOptions.Database.NewEmptyPerFixture)]
|
||||
public class PartialViewRepositoryTests : TestWithDatabaseBase
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.None)]
|
||||
public class PartialViewRepositoryTests : UmbracoIntegrationTest
|
||||
{
|
||||
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
|
||||
private IFileSystem _fileSystem;
|
||||
|
||||
public override void SetUp()
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
_fileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, LoggerFactory.CreateLogger<PhysicalFileSystem>(), Constants.SystemDirectories.MvcViews + "/Partials/");
|
||||
}
|
||||
|
||||
protected override void Compose()
|
||||
[TearDown]
|
||||
public void TearDownFiles()
|
||||
{
|
||||
base.Compose();
|
||||
|
||||
Composition.RegisterUnique(f => new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
//Delete all files
|
||||
Purge((PhysicalFileSystem)_fileSystem, "");
|
||||
_fileSystem = null;
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -42,7 +41,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var fileSystems = Mock.Of<IFileSystems>();
|
||||
Mock.Get(fileSystems).Setup(x => x.PartialViewsFileSystem).Returns(_fileSystem);
|
||||
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = provider.CreateScope())
|
||||
{
|
||||
var repository = new PartialViewRepository(fileSystems, IOHelper);
|
||||
@@ -101,15 +100,6 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
|
||||
//Delete all files
|
||||
Purge((PhysicalFileSystem)_fileSystem, "");
|
||||
_fileSystem = null;
|
||||
}
|
||||
|
||||
private void Purge(PhysicalFileSystem fs, string path)
|
||||
{
|
||||
@@ -5,33 +5,29 @@ using System.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Composing;
|
||||
using Umbraco.Core.Configuration;
|
||||
using Umbraco.Core.Configuration.Models;
|
||||
using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.Repositories.Implement;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Tests.Common.Builders;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Integration.Testing;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
namespace Umbraco.Tests.Persistence.Repositories
|
||||
namespace Umbraco.Tests.Integration.Umbraco.Infrastructure.Persistence.Repositories
|
||||
{
|
||||
[TestFixture]
|
||||
[UmbracoTest(WithApplication = true, Database = UmbracoTestOptions.Database.NewEmptyPerFixture)]
|
||||
public class ScriptRepositoryTest : TestWithDatabaseBase
|
||||
[UmbracoTest(Database = UmbracoTestOptions.Database.None)]
|
||||
public class ScriptRepositoryTest : UmbracoIntegrationTest
|
||||
{
|
||||
private IHostingEnvironment HostingEnvironment => GetRequiredService<IHostingEnvironment>();
|
||||
|
||||
private IFileSystems _fileSystems;
|
||||
private IFileSystem _fileSystem;
|
||||
|
||||
public override void SetUp()
|
||||
[SetUp]
|
||||
public void SetUpFileSystem()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
_fileSystem = new PhysicalFileSystem(IOHelper, HostingEnvironment, LoggerFactory.CreateLogger<PhysicalFileSystem>(), new GlobalSettings().UmbracoScriptsPath);
|
||||
Mock.Get(_fileSystems).Setup(x => x.ScriptsFileSystem).Returns(_fileSystem);
|
||||
@@ -41,24 +37,25 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDownFileSystem()
|
||||
{
|
||||
//Delete all files
|
||||
Purge(_fileSystems.ScriptsFileSystem, "");
|
||||
_fileSystems = null;
|
||||
}
|
||||
|
||||
private IScriptRepository CreateRepository()
|
||||
{
|
||||
var globalSettings = new GlobalSettings();
|
||||
return new ScriptRepository(_fileSystems, IOHelper, Microsoft.Extensions.Options.Options.Create(globalSettings));
|
||||
}
|
||||
|
||||
protected override void Compose()
|
||||
{
|
||||
base.Compose();
|
||||
|
||||
Composition.RegisterUnique(f => new DataEditorCollection(Enumerable.Empty<DataEditor>()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Instantiate_Repository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
// Act
|
||||
@@ -73,7 +70,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_Add_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -92,7 +89,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_Update_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -118,7 +115,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_Delete_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -138,7 +135,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_Get_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -157,7 +154,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_GetAll_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -185,7 +182,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_GetAll_With_Params_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -213,7 +210,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
public void Can_Perform_Exists_On_ScriptRepository()
|
||||
{
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -232,7 +229,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
const string content = "/// <reference name=\"MicrosoftAjax.js\"/>";
|
||||
|
||||
// Arrange
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -265,7 +262,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
{
|
||||
// unless noted otherwise, no changes / 7.2.8
|
||||
|
||||
var provider = TestObjects.GetScopeProvider(LoggerFactory);
|
||||
var provider = ScopeProvider;
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = CreateRepository();
|
||||
@@ -335,16 +332,6 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
|
||||
//Delete all files
|
||||
Purge(_fileSystems.ScriptsFileSystem, "");
|
||||
_fileSystems = null;
|
||||
}
|
||||
|
||||
private void Purge(IFileSystem fs, string path)
|
||||
{
|
||||
var files = fs.GetFiles(path, "*.js");
|
||||
@@ -216,7 +216,6 @@
|
||||
<Compile Include="Web\HttpCookieExtensionsTests.cs" />
|
||||
<Compile Include="Web\Mvc\HtmlStringUtilitiesTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\PetaPocoCachesTest.cs" />
|
||||
<Compile Include="Persistence\Repositories\PartialViewRepositoryTests.cs" />
|
||||
<Compile Include="Routing\RoutesCacheTests.cs" />
|
||||
<Compile Include="Routing\UrlRoutingTestBase.cs" />
|
||||
<Compile Include="Web\Mvc\RenderNoContentControllerTests.cs" />
|
||||
@@ -277,7 +276,6 @@
|
||||
<Compile Include="Persistence\DatabaseContextTests.cs" />
|
||||
<Compile Include="Persistence\NPocoTests\NPocoSqlTests.cs" />
|
||||
<Compile Include="Persistence\Querying\QueryBuilderTests.cs" />
|
||||
<Compile Include="Persistence\Repositories\ScriptRepositoryTest.cs" />
|
||||
<Compile Include="Persistence\Repositories\StylesheetRepositoryTest.cs" />
|
||||
<Compile Include="PublishedContent\PublishedContentMoreTests.cs" />
|
||||
<Compile Include="Cache\PublishedCache\PublishedContentCacheTests.cs" />
|
||||
|
||||
Reference in New Issue
Block a user