Adding unit tests for DictionaryRepository.
This commit is contained in:
@@ -117,7 +117,8 @@ namespace Umbraco.Core.IO
|
||||
|
||||
public Stream OpenFile(string path)
|
||||
{
|
||||
return File.OpenRead(GetFullPath(path));
|
||||
var fullPath = GetFullPath(path);
|
||||
return File.OpenRead(fullPath);
|
||||
}
|
||||
|
||||
public void DeleteFile(string path)
|
||||
|
||||
@@ -17,6 +17,10 @@ namespace Umbraco.Core.Models
|
||||
private string _itemKey;
|
||||
private IEnumerable<IDictionaryTranslation> _translations;
|
||||
|
||||
public DictionaryItem(string itemKey)
|
||||
: this(new Guid("41c7638d-f529-4bff-853e-59a0c2fb1bde"), itemKey)
|
||||
{}
|
||||
|
||||
public DictionaryItem(Guid parentId, string itemKey)
|
||||
{
|
||||
_parentId = parentId;
|
||||
@@ -77,6 +81,8 @@ namespace Umbraco.Core.Models
|
||||
{
|
||||
base.AddingEntity();
|
||||
|
||||
Key = Guid.NewGuid();
|
||||
|
||||
//If ParentId is not set we should default to the root parent id
|
||||
if(ParentId == Guid.Empty)
|
||||
_parentId = new Guid("41c7638d-f529-4bff-853e-59a0c2fb1bde");
|
||||
|
||||
@@ -258,8 +258,9 @@ namespace Umbraco.Core.Models
|
||||
/// <returns>True if valid, otherwise false</returns>
|
||||
public bool IsPropertyTypeValid(object value)
|
||||
{
|
||||
//Can't validate null values, so just allow it to pass the current validation
|
||||
if (value == null)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
//Check type if the type of the value match the type from the DataType/PropertyEditor
|
||||
Type type = value.GetType();
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Models.Rdbms
|
||||
|
||||
[Column("id")]
|
||||
[Index(IndexTypes.UniqueNonClustered)]
|
||||
public Guid Id { get; set; }
|
||||
public Guid UniqueId { get; set; }
|
||||
|
||||
[Column("parent")]
|
||||
public Guid Parent { get; set; }
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
return new DictionaryItem(dto.Parent, dto.Key)
|
||||
{
|
||||
Id = dto.PrimaryKey,
|
||||
Key = dto.Id
|
||||
Key = dto.UniqueId
|
||||
};
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
{
|
||||
return new DictionaryDto
|
||||
{
|
||||
Id = entity.Key,
|
||||
UniqueId = entity.Key,
|
||||
Key = entity.ItemKey,
|
||||
Parent = entity.ParentId,
|
||||
PrimaryKey = entity.Id,
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Umbraco.Core.Persistence.Factories
|
||||
var text = new LanguageTextDto
|
||||
{
|
||||
LanguageId = entity.Language.Id,
|
||||
UniqueId = entity.Key,
|
||||
UniqueId = _uniqueId,
|
||||
Value = entity.Value
|
||||
};
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Umbraco.Core.Persistence.Mappers
|
||||
internal override void BuildMap()
|
||||
{
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.Id, dto => dto.PrimaryKey);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.Key, dto => dto.Id);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.Key, dto => dto.UniqueId);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.ItemKey, dto => dto.Key);
|
||||
CacheMap<DictionaryItem, DictionaryDto>(src => src.ParentId, dto => dto.Parent);
|
||||
}
|
||||
|
||||
@@ -172,8 +172,9 @@ namespace Umbraco.Core.Persistence.Querying
|
||||
|
||||
if (m.Expression != null && m.Expression.NodeType != ExpressionType.Constant)
|
||||
{
|
||||
Database.Mapper = new ModelDtoMapper();
|
||||
var def = new Database.PocoData(m.Expression.Type);
|
||||
//Database.Mapper = new ModelDtoMapper();
|
||||
//var def = new Database.PocoData(m.Expression.Type);
|
||||
var def = new Database.PocoData(typeof(T));
|
||||
string field = GetFieldName(def, m.Member.Name);
|
||||
return field;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace Umbraco.Core.Persistence.Relators
|
||||
return Current;
|
||||
|
||||
// Is this the same DictionaryItem as the current one we're processing
|
||||
if (Current != null && Current.Id == a.Id)
|
||||
if (Current != null && Current.UniqueId == a.UniqueId)
|
||||
{
|
||||
// Yes, just add this LanguageTextDto to the current DictionaryItem's collection
|
||||
Current.LanguageTextDtos.Add(p);
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
foreach (var textDto in dto.LanguageTextDtos)
|
||||
{
|
||||
var language = _languageRepository.Get(textDto.LanguageId);
|
||||
var translationFactory = new DictionaryTranslationFactory(dto.Id, language);
|
||||
var translationFactory = new DictionaryTranslationFactory(dto.UniqueId, language);
|
||||
list.Add(translationFactory.BuildEntity(textDto));
|
||||
}
|
||||
entity.Translations = list;
|
||||
@@ -83,7 +83,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var translator = new SqlTranslator<IDictionaryItem>(sqlClause, query);
|
||||
var sql = translator.Translate();
|
||||
|
||||
var dtos = Database.Fetch<DictionaryDto, LanguageTextDto>(sql);
|
||||
var dtos = Database.Fetch<DictionaryDto, LanguageTextDto, DictionaryDto>(new DictionaryLanguageTextRelator().Map, sql);
|
||||
|
||||
foreach (var dto in dtos)
|
||||
{
|
||||
@@ -98,15 +98,23 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
protected override Sql GetBaseQuery(bool isCount)
|
||||
{
|
||||
var sql = new Sql();
|
||||
sql.Select(isCount ? "COUNT(*)" : "*");
|
||||
sql.From("cmsDictionary");
|
||||
sql.InnerJoin("cmsLanguageText ON ([cmsDictionary].[id] = [cmsLanguageText].[UniqueId])");
|
||||
if(isCount)
|
||||
{
|
||||
sql.Select("COUNT(*)");
|
||||
sql.From("cmsDictionary");
|
||||
}
|
||||
else
|
||||
{
|
||||
sql.Select("*");
|
||||
sql.From("cmsDictionary");
|
||||
sql.InnerJoin("cmsLanguageText ON ([cmsDictionary].[id] = [cmsLanguageText].[UniqueId])");
|
||||
}
|
||||
return sql;
|
||||
}
|
||||
|
||||
protected override string GetBaseWhereClause()
|
||||
{
|
||||
return "[cmsDictionary].[id] = @Id";
|
||||
return "[cmsDictionary].[pk] = @Id";
|
||||
}
|
||||
|
||||
protected override IEnumerable<string> GetDeleteClauses()
|
||||
@@ -128,7 +136,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override void PersistNewItem(IDictionaryItem entity)
|
||||
{
|
||||
((Entity)entity).AddingEntity();
|
||||
((DictionaryItem)entity).AddingEntity();
|
||||
|
||||
var factory = new DictionaryItemFactory();
|
||||
var dto = factory.BuildDto(entity);
|
||||
@@ -141,6 +149,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
var textDto = translationFactory.BuildDto(translation);
|
||||
translation.Id = Convert.ToInt32(Database.Insert(textDto));
|
||||
translation.Key = entity.Key;
|
||||
}
|
||||
|
||||
((ICanBeDirty)entity).ResetDirtyProperties();
|
||||
@@ -166,6 +175,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
else
|
||||
{
|
||||
translation.Id = Convert.ToInt32(Database.Insert(dto));
|
||||
translation.Key = entity.Key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,10 +196,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var list = Database.Fetch<DictionaryDto>("WHERE parent = @ParentId", new {ParentId = parentId});
|
||||
foreach (var dto in list)
|
||||
{
|
||||
RecursiveDelete(dto.Id);
|
||||
RecursiveDelete(dto.UniqueId);
|
||||
|
||||
Database.Delete<LanguageTextDto>("WHERE UniqueId = @Id", new { Id = dto.Id });
|
||||
Database.Delete<DictionaryDto>("WHERE id = @Id", new { Id = dto.Id });
|
||||
Database.Delete<LanguageTextDto>("WHERE UniqueId = @Id", new { Id = dto.UniqueId });
|
||||
Database.Delete<DictionaryDto>("WHERE id = @Id", new { Id = dto.UniqueId });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
|
||||
protected override int PerformCount(IQuery<IMacro> query)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var files = _fileSystem.GetFiles("", "*.macro");
|
||||
return files.Count();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<!-- Macros -->
|
||||
<Provider alias="macros" type="Umbraco.Core.IO.PhysicalFileSystem, Umbraco.Core">
|
||||
<Parameters>
|
||||
<add key="rootPath" value="\App_Data\Macros\" />
|
||||
<add key="rootPath" value="C:\Projects\Umbraco\src\Umbraco.Tests\App_Data\Macros" />
|
||||
<add key="rootUrl" value="/Macros/" />
|
||||
</Parameters>
|
||||
</Provider>
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Persistence.Querying;
|
||||
using Umbraco.Core.Persistence.Repositories;
|
||||
using Umbraco.Core.Persistence.UnitOfWork;
|
||||
using Umbraco.Tests.TestHelpers;
|
||||
@@ -33,39 +37,190 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Get_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var dictionaryItem = repository.Get(1);
|
||||
|
||||
// Assert
|
||||
Assert.That(dictionaryItem, Is.Not.Null);
|
||||
Assert.That(dictionaryItem.ItemKey, Is.EqualTo("Read More"));
|
||||
Assert.That(dictionaryItem.Translations.Any(), Is.True);
|
||||
Assert.That(dictionaryItem.Translations.Any(x => x == null), Is.False);
|
||||
Assert.That(dictionaryItem.Translations.First().Value, Is.EqualTo("Read More"));
|
||||
Assert.That(dictionaryItem.Translations.Last().Value, Is.EqualTo("Læs mere"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_GetAll_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var dictionaryItem = repository.Get(1);
|
||||
var dictionaryItems = repository.GetAll();
|
||||
|
||||
// Assert
|
||||
Assert.That(dictionaryItems, Is.Not.Null);
|
||||
Assert.That(dictionaryItems.Any(), Is.True);
|
||||
Assert.That(dictionaryItems.Any(x => x == null), Is.False);
|
||||
Assert.That(dictionaryItems.Count(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_GetAll_With_Params_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var dictionaryItems = repository.GetAll(1, 2);
|
||||
|
||||
// Assert
|
||||
Assert.That(dictionaryItems, Is.Not.Null);
|
||||
Assert.That(dictionaryItems.Any(), Is.True);
|
||||
Assert.That(dictionaryItems.Any(x => x == null), Is.False);
|
||||
Assert.That(dictionaryItems.Count(), Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_GetByQuery_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var query = Query<IDictionaryItem>.Builder.Where(x => x.ItemKey == "Article");
|
||||
var result = repository.GetByQuery(query);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.Not.Null);
|
||||
Assert.That(result.Any(), Is.True);
|
||||
Assert.That(result.FirstOrDefault().ItemKey, Is.EqualTo("Article"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Count_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var query = Query<IDictionaryItem>.Builder.Where(x => x.ItemKey.StartsWith("Read"));
|
||||
var result = repository.Count(query);
|
||||
|
||||
// Assert
|
||||
Assert.That(result, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Add_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
var language = languageRepository.Get(1);
|
||||
|
||||
var read = new DictionaryItem("Read");
|
||||
var translations = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(language, "Read")
|
||||
};
|
||||
read.Translations = translations;
|
||||
|
||||
// Act
|
||||
repository.AddOrUpdate(read);
|
||||
unitOfWork.Commit();
|
||||
|
||||
var exists = repository.Exists(read.Id);
|
||||
|
||||
// Assert
|
||||
Assert.That(read.HasIdentity, Is.True);
|
||||
Assert.That(exists, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Update_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var item = repository.Get(1);
|
||||
var translations = item.Translations.ToList();
|
||||
translations[0].Value = "Read even more";
|
||||
item.Translations = translations;
|
||||
|
||||
repository.AddOrUpdate(item);
|
||||
unitOfWork.Commit();
|
||||
|
||||
var dictionaryItem = repository.Get(1);
|
||||
|
||||
// Assert
|
||||
Assert.That(dictionaryItem, Is.Not.Null);
|
||||
Assert.That(dictionaryItem.Translations.Count(), Is.EqualTo(2));
|
||||
Assert.That(dictionaryItem.Translations.FirstOrDefault().Value, Is.EqualTo("Read even more"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Delete_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var item = repository.Get(1);
|
||||
repository.Delete(item);
|
||||
unitOfWork.Commit();
|
||||
|
||||
var exists = repository.Exists(1);
|
||||
|
||||
// Assert
|
||||
Assert.That(exists, Is.False);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Can_Perform_Exists_On_DictionaryRepository()
|
||||
{ }
|
||||
{
|
||||
// Arrange
|
||||
var provider = new PetaPocoUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var languageRepository = new LanguageRepository(unitOfWork);
|
||||
var repository = new DictionaryRepository(unitOfWork, languageRepository);
|
||||
|
||||
// Act
|
||||
var exists = repository.Exists(1);
|
||||
|
||||
// Assert
|
||||
Assert.That(exists, Is.True);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public override void TearDown()
|
||||
@@ -74,6 +229,29 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
}
|
||||
|
||||
public void CreateTestData()
|
||||
{ }
|
||||
{
|
||||
var language = ServiceContext.LocalizationService.GetLanguageByCultureCode("en-US");
|
||||
|
||||
var languageDK = new Language("da-DK") { CultureName = "da-DK" };
|
||||
ServiceContext.LocalizationService.Save(languageDK);//Id 2
|
||||
|
||||
var readMore = new DictionaryItem("Read More");
|
||||
var translations = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(language, "Read More"),
|
||||
new DictionaryTranslation(languageDK, "Læs mere")
|
||||
};
|
||||
readMore.Translations = translations;
|
||||
ServiceContext.LocalizationService.Save(readMore);//Id 1
|
||||
|
||||
var article = new DictionaryItem("Article");
|
||||
var translations2 = new List<IDictionaryTranslation>
|
||||
{
|
||||
new DictionaryTranslation(language, "Article"),
|
||||
new DictionaryTranslation(languageDK, "Artikel")
|
||||
};
|
||||
article.Translations = translations2;
|
||||
ServiceContext.LocalizationService.Save(article);//Id 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
|
||||
// Act
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
|
||||
// Assert
|
||||
Assert.That(repository, Is.Not.Null);
|
||||
@@ -33,7 +33,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
|
||||
// Act
|
||||
bool exists = repository.Exists("commentList");
|
||||
@@ -48,7 +48,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
|
||||
// Act
|
||||
bool exists = repository.Exists("testMacro");
|
||||
@@ -63,7 +63,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
|
||||
// Act
|
||||
var macro = new Macro { Alias = "testMacro", CacheByPage = false, CacheByMember = false, DontRender = true, Name = "Test Macro", Xslt = "/xslt/testMacro.xslt", UseInEditor = false };
|
||||
@@ -84,7 +84,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
var macro = CreateMacro("updateMacro", "Update Macro");
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
@@ -109,7 +109,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
var macro = CreateMacro("deleteMacro", "Delete Macro");
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
@@ -129,14 +129,14 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
var macro = CreateMacro("getMacro", "Get Macro");
|
||||
repository.AddOrUpdate(macro);
|
||||
unitOfWork.Commit();
|
||||
|
||||
// Act
|
||||
var unitOfWork2 = provider.GetUnitOfWork();
|
||||
var repository2 = new MacroRepository(unitOfWork2, InMemoryCacheProvider.Current);
|
||||
var repository2 = new MacroRepository(unitOfWork2, NullCacheProvider.Current);
|
||||
var macro1 = repository2.Get("getMacro");
|
||||
|
||||
// Assert
|
||||
@@ -153,7 +153,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
// Arrange
|
||||
var provider = new FileUnitOfWorkProvider();
|
||||
var unitOfWork = provider.GetUnitOfWork();
|
||||
var repository = new MacroRepository(unitOfWork, InMemoryCacheProvider.Current);
|
||||
var repository = new MacroRepository(unitOfWork, NullCacheProvider.Current);
|
||||
|
||||
// Act
|
||||
var macros = repository.GetAll();
|
||||
|
||||
Reference in New Issue
Block a user