From 4fc25dcfebf41000b26d0f5c24ad1abbc95fc1a8 Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Thu, 4 Aug 2022 13:17:11 +0800 Subject: [PATCH] Add unit test --- .../UnitTest/Models/poetry_video_comment.cs | 2 +- .../SqlServerTest/UnitTest/UnitOneToOne12.cs | 32 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/Models/poetry_video_comment.cs b/Src/Asp.Net/SqlServerTest/UnitTest/Models/poetry_video_comment.cs index 8e296b828..61060ba0b 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/Models/poetry_video_comment.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/Models/poetry_video_comment.cs @@ -13,7 +13,7 @@ namespace SqlSugarDemo { [SugarColumn(IsIgnore = true)] [Navigate(NavigateType.OneToOne, nameof(user_id))] - public user_name_simple CommentUser { set; get; } + public user_name_simple UserInfo { set; get; } [SugarColumn(IsIgnore = true)] [Navigate(NavigateType.OneToOne, nameof(reply_user_id))] diff --git a/Src/Asp.Net/SqlServerTest/UnitTest/UnitOneToOne12.cs b/Src/Asp.Net/SqlServerTest/UnitTest/UnitOneToOne12.cs index 01fcdce80..98fe56b8b 100644 --- a/Src/Asp.Net/SqlServerTest/UnitTest/UnitOneToOne12.cs +++ b/Src/Asp.Net/SqlServerTest/UnitTest/UnitOneToOne12.cs @@ -26,27 +26,35 @@ namespace OrmTest }).ExecuteReturnIdentity(); db.Insertable(new poetry_video_comment() { - first_reply_id = 1, - reply_user_id = userid2, - user_id = userid2 + first_reply_id = 0, + reply_user_id = 0, + user_id = 0 }).ExecuteReturnIdentity(); db.Insertable(new poetry_video_comment() { - first_reply_id = 1, + first_reply_id = 2, reply_user_id = userid, user_id = userid2 }).ExecuteReturnIdentity(); - db.Insertable(new poetry_video_comment() - { - first_reply_id = 11, - reply_user_id = 11, - user_id = 11 - }).ExecuteReturnIdentity(); + var x = db.Queryable().ToList(); + //db.Insertable(new poetry_video_comment() + //{ + // first_reply_id = 11, + // reply_user_id = 11, + // user_id = 11 + //}).ExecuteReturnIdentity(); var list = db.Queryable() .Includes(o => o.FirstReply, o => o.ReplyUser) - .Includes(o => o.FirstReply, o => o.CommentUser) + .Includes(o => o.FirstReply, o => o.UserInfo) .ToList(); - + if (list.Last().FirstReply.UserInfo == null) + { + throw new Exception("unit error"); + } + if (list.Last().FirstReply.ReplyUser == null) + { + throw new Exception("unit error"); + } } } }