Skip to content

Commit a7b15dd

Browse files
2881028810
authored andcommitted
- 调整 Aop.AuditValue 单元测试;
1 parent 33612bd commit a7b15dd

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

FreeSql.Tests/FreeSql.Tests.Provider.MySqlConnector/MySqlConnector/MySqlAopTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ class NowAttribute: Attribute { }
2020
[Fact]
2121
public void AuditValue()
2222
{
23-
var now = DateTime.Now;
23+
var date = DateTime.Now.Date;
2424
var item = new TestAuditValue();
2525

2626
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
2727
{
2828
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
29-
e.Value = DateTime.Now;
29+
e.Value = DateTime.Now.Date;
3030
};
3131
g.mysql.Aop.AuditValue += audit;
3232

3333
g.mysql.Insert(item).ExecuteAffrows();
3434

3535
g.mysql.Aop.AuditValue -= audit;
3636

37-
Assert.Equal(item.createtime.Date, now.Date);
37+
Assert.Equal(item.createtime, date);
3838
}
3939
}
4040
}

FreeSql.Tests/FreeSql.Tests/MySql/MySqlAopTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ class NowAttribute: Attribute { }
2020
[Fact]
2121
public void AuditValue()
2222
{
23-
var now = DateTime.Now;
23+
var date = DateTime.Now.Date;
2424
var item = new TestAuditValue();
2525

2626
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
2727
{
2828
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
29-
e.Value = DateTime.Now;
29+
e.Value = DateTime.Now.Date;
3030
};
3131
g.mysql.Aop.AuditValue += audit;
3232

3333
g.mysql.Insert(item).ExecuteAffrows();
3434

3535
g.mysql.Aop.AuditValue -= audit;
3636

37-
Assert.Equal(item.createtime.Date, now.Date);
37+
Assert.Equal(item.createtime, date);
3838
}
3939
}
4040
}

FreeSql.Tests/FreeSql.Tests/Oracle/OracleAopTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ class NowAttribute: Attribute { }
2020
[Fact]
2121
public void AuditValue()
2222
{
23-
var now = DateTime.Now;
23+
var date = DateTime.Now.Date;
2424
var item = new TestAuditValue();
2525

2626
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
2727
{
2828
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
29-
e.Value = DateTime.Now;
29+
e.Value = DateTime.Now.Date;
3030
};
3131
g.oracle.Aop.AuditValue += audit;
3232

3333
g.oracle.Insert(item).ExecuteAffrows();
3434

3535
g.oracle.Aop.AuditValue -= audit;
3636

37-
Assert.Equal(item.createtime.Date, now.Date);
37+
Assert.Equal(item.createtime, date);
3838
}
3939
}
4040
}

FreeSql.Tests/FreeSql.Tests/PostgreSQL/PostgreSQLAopTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ class NowAttribute: Attribute { }
2020
[Fact]
2121
public void AuditValue()
2222
{
23-
var now = DateTime.Now;
23+
var date = DateTime.Now.Date;
2424
var item = new TestAuditValue();
2525

2626
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
2727
{
2828
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
29-
e.Value = DateTime.Now;
29+
e.Value = DateTime.Now.Date;
3030
};
3131
g.pgsql.Aop.AuditValue += audit;
3232

3333
g.pgsql.Insert(item).ExecuteAffrows();
3434

3535
g.pgsql.Aop.AuditValue -= audit;
3636

37-
Assert.Equal(item.createtime.Date, now.Date);
37+
Assert.Equal(item.createtime, date);
3838
}
3939
}
4040
}

FreeSql.Tests/FreeSql.Tests/SqlServer/SqlServerAopTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ class NowAttribute: Attribute { }
2020
[Fact]
2121
public void AuditValue()
2222
{
23-
var now = DateTime.Now;
23+
var date = DateTime.Now.Date;
2424
var item = new TestAuditValue();
2525

2626
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
2727
{
2828
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
29-
e.Value = DateTime.Now;
29+
e.Value = DateTime.Now.Date;
3030
};
3131
g.sqlserver.Aop.AuditValue += audit;
3232

3333
g.sqlserver.Insert(item).ExecuteAffrows();
3434

3535
g.sqlserver.Aop.AuditValue -= audit;
3636

37-
Assert.Equal(item.createtime.Date, now.Date);
37+
Assert.Equal(item.createtime, date);
3838
}
3939
}
4040
}

FreeSql.Tests/FreeSql.Tests/Sqlite/SqliteAopTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ class NowAttribute: Attribute { }
2020
[Fact]
2121
public void AuditValue()
2222
{
23-
var now = DateTime.Now;
23+
var date = DateTime.Now.Date;
2424
var item = new TestAuditValue();
2525

2626
EventHandler<Aop.AuditValueEventArgs> audit = (s, e) =>
2727
{
2828
if (e.Property.GetCustomAttribute<NowAttribute>(false) != null)
29-
e.Value = DateTime.Now;
29+
e.Value = DateTime.Now.Date;
3030
};
3131
g.sqlite.Aop.AuditValue += audit;
3232

3333
g.sqlite.Insert(item).ExecuteAffrows();
3434

3535
g.sqlite.Aop.AuditValue -= audit;
3636

37-
Assert.Equal(item.createtime.Date, now.Date);
37+
Assert.Equal(item.createtime, date);
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)