Files
Umbraco-CMS/src/Umbraco.Tests/Persistence/Repositories/AuditRepositoryTest.cs

34 lines
1.1 KiB
C#
Raw Normal View History

2017-07-20 11:21:28 +02:00
using System.Linq;
using NUnit.Framework;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Rdbms;
using Umbraco.Core.Persistence.Repositories;
2017-12-07 16:45:25 +01:00
using Umbraco.Core.Persistence.Repositories.Implement;
2017-12-15 11:19:03 +01:00
using Umbraco.Core.Scoping;
using Umbraco.Tests.TestHelpers;
2016-12-16 10:40:14 +01:00
using Umbraco.Tests.Testing;
namespace Umbraco.Tests.Persistence.Repositories
{
[TestFixture]
2016-11-05 19:23:55 +01:00
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
2016-10-13 21:08:07 +02:00
public class AuditRepositoryTest : TestWithDatabaseBase
{
[Test]
public void Can_Add_Audit_Entry()
{
2017-12-12 15:04:13 +01:00
var sp = TestObjects.GetScopeProvider(Logger);
using (var scope = sp.CreateScope())
{
2017-12-15 11:19:03 +01:00
var repo = new AuditRepository((IScopeAccessor) sp, CacheHelper, Logger);
2017-12-07 16:45:25 +01:00
repo.Save(new AuditItem(-1, "This is a System audit trail", AuditType.System, 0));
2017-12-12 15:04:13 +01:00
var dtos = scope.Database.Fetch<LogDto>("WHERE id > -1");
2017-05-12 14:49:44 +02:00
Assert.That(dtos.Any(), Is.True);
Assert.That(dtos.First().Comment, Is.EqualTo("This is a System audit trail"));
}
}
}
2017-07-20 11:21:28 +02:00
}