Cleanup and Refactor
This commit is contained in:
@@ -7,10 +7,8 @@ using Umbraco.Core.Configuration.UmbracoSettings;
|
||||
using Umbraco.Core.Composing;
|
||||
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.Core.Scoping;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
using Umbraco.Tests.Testing;
|
||||
|
||||
@@ -20,13 +18,16 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
[UmbracoTest(WithApplication = true, Database = UmbracoTestOptions.Database.NewEmptyPerFixture)]
|
||||
public class ScriptRepositoryTest : TestWithDatabaseBase
|
||||
{
|
||||
private IFileSystems _fileSystems;
|
||||
private IFileSystem _fileSystem;
|
||||
|
||||
public override void SetUp()
|
||||
{
|
||||
base.SetUp();
|
||||
|
||||
_fileSystems = Mock.Of<IFileSystems>();
|
||||
_fileSystem = new PhysicalFileSystem(SystemDirectories.Scripts);
|
||||
Mock.Get(_fileSystems).Setup(x => x.ScriptsFileSystem).Returns(_fileSystem);
|
||||
using (var stream = CreateStream("Umbraco.Sys.registerNamespace(\"Umbraco.Utils\");"))
|
||||
{
|
||||
_fileSystem.AddFile("test-script.js", stream);
|
||||
@@ -47,9 +48,8 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
|
||||
// Act
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
// Assert
|
||||
Assert.That(repository, Is.Not.Null);
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
// Act
|
||||
var script = new Script("test-add-script.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
@@ -82,7 +82,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
// Act
|
||||
var script = new Script("test-updated-script.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
@@ -108,7 +108,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
// Act
|
||||
var script = repository.Get("test-script.js");
|
||||
@@ -128,7 +128,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
// Act
|
||||
var exists = repository.Get("test-script.js");
|
||||
@@ -147,7 +147,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
var script = new Script("test-script1.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
repository.Save(script);
|
||||
@@ -175,7 +175,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
var script = new Script("test-script1.js") { Content = "/// <reference name=\"MicrosoftAjax.js\"/>" };
|
||||
repository.Save(script);
|
||||
@@ -203,7 +203,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
// Act
|
||||
var exists = repository.Exists("test-script.js");
|
||||
@@ -222,7 +222,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
var script = new Script("test-move-script.js") { Content = content };
|
||||
repository.Save(script);
|
||||
@@ -255,7 +255,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var provider = TestObjects.GetScopeProvider(Logger);
|
||||
using (var scope = ScopeProvider.CreateScope())
|
||||
{
|
||||
var repository = new ScriptRepository(_fileSystem, Mock.Of<IContentSection>());
|
||||
var repository = new ScriptRepository(_fileSystems, Mock.Of<IContentSection>());
|
||||
|
||||
var script = new Script("test-path-1.js") { Content = "// script" };
|
||||
repository.Save(script);
|
||||
@@ -328,11 +328,11 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
base.TearDown();
|
||||
|
||||
//Delete all files
|
||||
Purge((PhysicalFileSystem) _fileSystem, "");
|
||||
_fileSystem = null;
|
||||
Purge(_fileSystems.ScriptsFileSystem, "");
|
||||
_fileSystems = null;
|
||||
}
|
||||
|
||||
private void Purge(PhysicalFileSystem fs, string path)
|
||||
private void Purge(IFileSystem fs, string path)
|
||||
{
|
||||
var files = fs.GetFiles(path, "*.js");
|
||||
foreach (var file in files)
|
||||
|
||||
Reference in New Issue
Block a user