mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-16 07:52:50 +08:00
41 lines
981 B
C#
41 lines
981 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using Xunit;
|
|
|
|
namespace FreeSql.Tests.Custom.Oracle
|
|
{
|
|
public class OracleAopTest
|
|
{
|
|
|
|
class TestAuditValue
|
|
{
|
|
public Guid id { get; set; }
|
|
[Now]
|
|
public DateTime createtime { get; set; }
|
|
}
|
|
class NowAttribute: Attribute { }
|
|
|
|
[Fact]
|
|
public void AuditValue()
|
|
{
|
|
var date = DateTime.Now.Date;
|
|
var item = new TestAuditValue();
|
|
|
|
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
|
|
{
|
|
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
|
|
e.Value = DateTime.Now.Date;
|
|
};
|
|
g.oracle.Aop.AuditValue += audit;
|
|
|
|
g.oracle.Insert(item).ExecuteAffrows();
|
|
|
|
g.oracle.Aop.AuditValue -= audit;
|
|
|
|
Assert.Equal(item.createtime, date);
|
|
}
|
|
}
|
|
}
|