Пример #1
0
        public void RegisterAuditTypeTwiceExceptionTest()
        {
            AuditDbContext context = new AuditDbContext("test");

            AuditDbContext.RegisterAuditType(typeof(TestEntity), typeof(TestEntityAudit));
            AuditDbContext.RegisterAuditType(typeof(TestEntity), typeof(TestEntityAudit));
        }
Пример #2
0
        public void UpdateByAuditTestMethod()
        {
            var repository = LocalIoCContainer.Resolve <ISimpleDataEntityRepository>();

            Assert.IsTrue(AuditDbContext.AuditEnabled);

            AuditDbContext.RegisterAuditType(typeof(SimpleDataEntity), typeof(SimpleDataEntityAudit));

            var itemToUpdate = repository.Find(2);

            itemToUpdate.Name = "Updated Name 3";
            repository.Update(itemToUpdate, x => x.Id == 2);

            repository.Save("UserName2");

            var actual = repository.Find(2);

            var auditactual = repository.GetExistingContext().SimpleDataEntityAudits.Where(x => x.AuditSourceId == 2).FirstOrDefault();

            Assert.AreEqual("Updated Name 3", actual.Name);
            Assert.AreEqual("Test 2", auditactual?.Name);
            Assert.AreEqual("UserName2", auditactual?.AuditUser);

            repository.Dispose();
        }
Пример #3
0
        public void RegisterAuditTypeEntityExceptionTest2()
        {
            AuditDbContext context = new AuditDbContext("test");

            AuditDbContext.RegisterAuditType(typeof(TestEntity), typeof(TestInvalidAuditEntity));
        }
Пример #4
0
        public void RegisterAuditTypeTest()
        {
            AuditDbContext context = new AuditDbContext("test");

            AuditDbContext.RegisterAuditType(typeof(TestEntityWithComplexType), typeof(TestEntityWithComplexTypeAudit));
        }