Fixing tests - file systems
This commit is contained in:
@@ -147,15 +147,20 @@ namespace Umbraco.Tests.Services.Importing
|
||||
var xml = XElement.Parse(strXml);
|
||||
var element = xml.Descendants("Templates").First();
|
||||
var packagingService = ServiceContext.PackagingService;
|
||||
var init = ServiceContext.FileService.GetTemplates().Count();
|
||||
|
||||
// Act
|
||||
var templates = packagingService.ImportTemplates(element);
|
||||
var numberOfTemplates = (from doc in element.Elements("Template") select doc).Count();
|
||||
var allTemplates = ServiceContext.FileService.GetTemplates();
|
||||
|
||||
// Assert
|
||||
Assert.That(templates, Is.Not.Null);
|
||||
Assert.That(templates.Any(), Is.True);
|
||||
Assert.That(templates.Count(), Is.EqualTo(numberOfTemplates));
|
||||
|
||||
Assert.AreEqual(init + numberOfTemplates, allTemplates.Count());
|
||||
Assert.IsTrue(allTemplates.All(x => x.Content.Contains("UmbracoTemplatePage")));
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
SetupApplicationContext();
|
||||
|
||||
InitializeMappers();
|
||||
InitializeMappers();
|
||||
|
||||
FreezeResolution();
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
public override void TearDown()
|
||||
{
|
||||
base.TearDown();
|
||||
|
||||
|
||||
//reset settings
|
||||
SettingsForTests.Reset();
|
||||
UmbracoContext.Current = null;
|
||||
@@ -97,9 +97,10 @@ namespace Umbraco.Tests.TestHelpers
|
||||
|
||||
protected virtual void ConfigureContainer()
|
||||
{
|
||||
// oh no! should not use a container in unit tests?
|
||||
var settings = SettingsForTests.GetDefault();
|
||||
|
||||
//register mappers
|
||||
//register mappers
|
||||
Container.RegisterFrom<CoreModelMappersCompositionRoot>();
|
||||
Container.RegisterFrom<WebModelMappersCompositionRoot>();
|
||||
|
||||
@@ -109,7 +110,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
//Default Datalayer/Repositories/SQL/Database/etc...
|
||||
Container.RegisterFrom<RepositoryCompositionRoot>();
|
||||
|
||||
//register basic stuff that might need to be there for some container resolvers to work, we can
|
||||
//register basic stuff that might need to be there for some container resolvers to work, we can
|
||||
// add more to this in base classes in resolution freezing
|
||||
Container.RegisterSingleton<ILogger>(factory => Logger);
|
||||
Container.Register<CacheHelper>(factory => CacheHelper);
|
||||
@@ -127,8 +128,12 @@ namespace Umbraco.Tests.TestHelpers
|
||||
Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "PartialViewFileSystem");
|
||||
Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "PartialViewMacroFileSystem");
|
||||
Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "StylesheetFileSystem");
|
||||
Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "MasterpageFileSystem");
|
||||
Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "ViewFileSystem");
|
||||
|
||||
// need real file systems here as templates content is on-disk only
|
||||
//Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "MasterpageFileSystem");
|
||||
//Container.RegisterSingleton<IFileSystem>(factory => Mock.Of<IFileSystem>(), "ViewFileSystem");
|
||||
Container.RegisterSingleton<IFileSystem>(factory => new PhysicalFileSystem("Views", "/views"), "ViewFileSystem");
|
||||
Container.RegisterSingleton<IFileSystem>(factory => new PhysicalFileSystem("MasterPages", "/masterpages"), "MasterpageFileSystem");
|
||||
}
|
||||
|
||||
private static readonly object Locker = new object();
|
||||
@@ -173,7 +178,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// By default this returns false which means the plugin manager will not be reset so it doesn't need to re-scan
|
||||
/// By default this returns false which means the plugin manager will not be reset so it doesn't need to re-scan
|
||||
/// all of the assemblies. Inheritors can override this if plugin manager resetting is required, generally needs
|
||||
/// to be set to true if the SetupPluginManager has been overridden.
|
||||
/// </summary>
|
||||
@@ -207,7 +212,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
/// Inheritors can override this if they wish to create a custom application context
|
||||
/// </summary>
|
||||
protected virtual void SetupApplicationContext()
|
||||
{
|
||||
{
|
||||
var evtMsgs = new TransientMessagesFactory();
|
||||
ApplicationContext.Current = new ApplicationContext(
|
||||
//assign the db context
|
||||
@@ -215,13 +220,13 @@ namespace Umbraco.Tests.TestHelpers
|
||||
Logger, SqlSyntax, "System.Data.SqlServerCe.4.0"),
|
||||
//assign the service context
|
||||
ServiceContextHelper.GetServiceContext(
|
||||
Container.GetInstance<RepositoryFactory>(),
|
||||
new NPocoUnitOfWorkProvider(Logger),
|
||||
Container.GetInstance<RepositoryFactory>(),
|
||||
new NPocoUnitOfWorkProvider(Logger),
|
||||
new FileUnitOfWorkProvider(),
|
||||
new PublishingStrategy(evtMsgs, Logger),
|
||||
CacheHelper,
|
||||
Logger,
|
||||
evtMsgs,
|
||||
new PublishingStrategy(evtMsgs, Logger),
|
||||
CacheHelper,
|
||||
Logger,
|
||||
evtMsgs,
|
||||
Enumerable.Empty<IUrlSegmentProvider>()),
|
||||
CacheHelper,
|
||||
ProfilingLogger)
|
||||
@@ -273,7 +278,7 @@ namespace Umbraco.Tests.TestHelpers
|
||||
protected ProfilingLogger ProfilingLogger { get; private set; }
|
||||
protected CacheHelper CacheHelper { get; private set; }
|
||||
|
||||
//I know tests shouldn't use IoC, but for all these tests inheriting from this class are integration tests
|
||||
//I know tests shouldn't use IoC, but for all these tests inheriting from this class are integration tests
|
||||
// and the number of these will hopefully start getting greatly reduced now that most things are mockable.
|
||||
internal IServiceContainer Container { get; private set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user