fixes a couple of tests

This commit is contained in:
Shannon
2015-01-07 10:39:00 +11:00
parent 341239648d
commit d4f28fcd85
2 changed files with 22 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ using System.Linq;
using System.Xml;
using System.Xml.Linq;
using System.Xml.XPath;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Services
{
@@ -80,7 +81,8 @@ namespace Umbraco.Core.Services
{
if (_xmlSource.ContainsKey(culture) == false)
{
throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service");
LogHelper.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
return result;
}
//convert all areas + keys to a single key with a '/'
@@ -103,7 +105,8 @@ namespace Umbraco.Core.Services
{
if (_dictionarySource.ContainsKey(culture) == false)
{
throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service");
LogHelper.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
return result;
}
//convert all areas + keys to a single key with a '/'
@@ -137,7 +140,8 @@ namespace Umbraco.Core.Services
{
if (_dictionarySource.ContainsKey(culture) == false)
{
throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service");
LogHelper.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
return "[" + key + "]";
}
var cultureSource = _dictionarySource[culture];
@@ -174,7 +178,8 @@ namespace Umbraco.Core.Services
{
if (_xmlSource.ContainsKey(culture) == false)
{
throw new NullReferenceException("The culture specified " + culture + " was not found in any configured sources for this service");
LogHelper.Warn<LocalizedTextService>("The culture specified {0} was not found in any configured sources for this service", () => culture);
return "[" + key + "]";
}
var cultureSource = _xmlSource[culture].Value;

View File

@@ -4,6 +4,7 @@ using System.Globalization;
using System.IO;
using System.Xml.Linq;
using Umbraco.Core.Cache;
using Umbraco.Core.Logging;
namespace Umbraco.Core.Services
{
@@ -20,7 +21,15 @@ namespace Umbraco.Core.Services
if (cache == null) throw new ArgumentNullException("cache");
if (fileSourceFolder == null) throw new ArgumentNullException("fileSourceFolder");
_cache = cache;
_fileSourceFolder = fileSourceFolder;
if (fileSourceFolder.Exists == false)
{
LogHelper.Warn<LocalizedTextServiceFileSources>("The folder does not exist: {0}, therefore no sources will be discovered", () => fileSourceFolder.FullName);
}
else
{
_fileSourceFolder = fileSourceFolder;
}
}
/// <summary>
@@ -30,6 +39,9 @@ namespace Umbraco.Core.Services
public IDictionary<CultureInfo, Lazy<XDocument>> GetXmlSources()
{
var result = new Dictionary<CultureInfo, Lazy<XDocument>>();
if (_fileSourceFolder == null) return result;
foreach (var fileInfo in _fileSourceFolder.GetFiles("*.xml"))
{
var localCopy = fileInfo;