Skip to content

Commit 4e620d9

Browse files
committed
Adjust xnuit test for appveyor 🐬
1 parent bd350a0 commit 4e620d9

File tree

14 files changed

+276
-157
lines changed

14 files changed

+276
-157
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ healthchecksdb
343343

344344
# wwwroot/images
345345
*images/
346-
Blog.Core/WMBlog.db
346+
!Blog.Core/WMBlog.db
347347
.1YourProject
348348
.PublishFiles
349349
!Blog.Core.Webapi.Template.1.0.0.nupkg

Blog.Core.Common/Helper/Appsettings.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class Appsettings
2929
// .Build();
3030
//}
3131

32-
public Appsettings(IHostingEnvironment env)
32+
public Appsettings(string contentPath)
3333
{
3434
string Path = "appsettings.json";
3535

@@ -43,7 +43,7 @@ public Appsettings(IHostingEnvironment env)
4343
//.Build();
4444

4545

46-
var contentPath = env.ContentRootPath;
46+
//var contentPath = env.ContentRootPath;
4747
Configuration = new ConfigurationBuilder()
4848
.SetBasePath(contentPath)
4949
.Add(new JsonConfigurationSource { Path = Path, Optional = false, ReloadOnChange = true })//这样的话,可以直接读目录里的json文件,而不是 bin 文件夹下的,所以不用修改复制属性

Blog.Core.Common/LogHelper/LogLock.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ public class LogLock
1919
static int FailedCount = 0;
2020
static string contentRoot = string.Empty;
2121

22-
public LogLock(IHostingEnvironment env) {
23-
contentRoot = env.ContentRootPath;
22+
public LogLock(string ContentRootPath) {
23+
contentRoot = ContentRootPath;
2424
}
2525

2626
public static void OutSql2Log(string filename, string[] dataParas)

Blog.Core.Model/Seed/DBSeed.cs

+123-119
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Blog.Core.Common.Helper;
1+
using Blog.Core.Common;
2+
using Blog.Core.Common.Helper;
23
using Blog.Core.Model.Models;
34
using SqlSugar;
45
using System;
@@ -65,126 +66,129 @@ public static async Task SeedAsync(MyContext myContext)
6566
Console.WriteLine("Database:WMBlog created success!");
6667
Console.WriteLine();
6768

68-
Console.WriteLine("Seeding database...");
69-
70-
#region BlogArticle
71-
if (!await myContext.Db.Queryable<BlogArticle>().AnyAsync())
72-
{
73-
myContext.GetEntityDB<BlogArticle>().InsertRange(JsonHelper.ParseFormByJson<List<BlogArticle>>(GetNetData.Get(string.Format(GitJsonFileFormat, "BlogArticle"))));
74-
Console.WriteLine("Table:BlogArticle created success!");
75-
}
76-
else
77-
{
78-
Console.WriteLine("Table:BlogArticle already exists...");
79-
}
80-
#endregion
81-
82-
83-
#region Module
84-
if (!await myContext.Db.Queryable<Module>().AnyAsync())
85-
{
86-
myContext.GetEntityDB<Module>().InsertRange(JsonHelper.ParseFormByJson<List<Module>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Module"))));
87-
Console.WriteLine("Table:Module created success!");
88-
}
89-
else
90-
{
91-
Console.WriteLine("Table:Module already exists...");
92-
}
93-
#endregion
94-
95-
96-
#region Permission
97-
if (!await myContext.Db.Queryable<Permission>().AnyAsync())
98-
{
99-
myContext.GetEntityDB<Permission>().InsertRange(JsonHelper.ParseFormByJson<List<Permission>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Permission"))));
100-
Console.WriteLine("Table:Permission created success!");
101-
}
102-
else
103-
{
104-
Console.WriteLine("Table:Permission already exists...");
105-
}
106-
#endregion
107-
108-
109-
#region Role
110-
if (!await myContext.Db.Queryable<Role>().AnyAsync())
111-
{
112-
myContext.GetEntityDB<Role>().InsertRange(JsonHelper.ParseFormByJson<List<Role>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Role"))));
113-
Console.WriteLine("Table:Role created success!");
114-
}
115-
else
116-
{
117-
Console.WriteLine("Table:Role already exists...");
118-
}
119-
#endregion
120-
121-
122-
#region RoleModulePermission
123-
if (!await myContext.Db.Queryable<RoleModulePermission>().AnyAsync())
124-
{
125-
myContext.GetEntityDB<RoleModulePermission>().InsertRange(JsonHelper.ParseFormByJson<List<RoleModulePermission>>(GetNetData.Get(string.Format(GitJsonFileFormat, "RoleModulePermission"))));
126-
Console.WriteLine("Table:RoleModulePermission created success!");
127-
}
128-
else
129-
{
130-
Console.WriteLine("Table:RoleModulePermission already exists...");
131-
}
132-
#endregion
133-
134-
135-
#region Topic
136-
if (!await myContext.Db.Queryable<Topic>().AnyAsync())
137-
{
138-
myContext.GetEntityDB<Topic>().InsertRange(JsonHelper.ParseFormByJson<List<Topic>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Topic"))));
139-
Console.WriteLine("Table:Topic created success!");
140-
}
141-
else
142-
{
143-
Console.WriteLine("Table:Topic already exists...");
69+
if (Appsettings.app(new string[] { "AppSettings", "SeedDBDataEnabled" }).ObjToBool())
70+
{
71+
Console.WriteLine("Seeding database...");
72+
73+
#region BlogArticle
74+
if (!await myContext.Db.Queryable<BlogArticle>().AnyAsync())
75+
{
76+
myContext.GetEntityDB<BlogArticle>().InsertRange(JsonHelper.ParseFormByJson<List<BlogArticle>>(GetNetData.Get(string.Format(GitJsonFileFormat, "BlogArticle"))));
77+
Console.WriteLine("Table:BlogArticle created success!");
78+
}
79+
else
80+
{
81+
Console.WriteLine("Table:BlogArticle already exists...");
82+
}
83+
#endregion
84+
85+
86+
#region Module
87+
if (!await myContext.Db.Queryable<Module>().AnyAsync())
88+
{
89+
myContext.GetEntityDB<Module>().InsertRange(JsonHelper.ParseFormByJson<List<Module>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Module"))));
90+
Console.WriteLine("Table:Module created success!");
91+
}
92+
else
93+
{
94+
Console.WriteLine("Table:Module already exists...");
95+
}
96+
#endregion
97+
98+
99+
#region Permission
100+
if (!await myContext.Db.Queryable<Permission>().AnyAsync())
101+
{
102+
myContext.GetEntityDB<Permission>().InsertRange(JsonHelper.ParseFormByJson<List<Permission>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Permission"))));
103+
Console.WriteLine("Table:Permission created success!");
104+
}
105+
else
106+
{
107+
Console.WriteLine("Table:Permission already exists...");
108+
}
109+
#endregion
110+
111+
112+
#region Role
113+
if (!await myContext.Db.Queryable<Role>().AnyAsync())
114+
{
115+
myContext.GetEntityDB<Role>().InsertRange(JsonHelper.ParseFormByJson<List<Role>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Role"))));
116+
Console.WriteLine("Table:Role created success!");
117+
}
118+
else
119+
{
120+
Console.WriteLine("Table:Role already exists...");
121+
}
122+
#endregion
123+
124+
125+
#region RoleModulePermission
126+
if (!await myContext.Db.Queryable<RoleModulePermission>().AnyAsync())
127+
{
128+
myContext.GetEntityDB<RoleModulePermission>().InsertRange(JsonHelper.ParseFormByJson<List<RoleModulePermission>>(GetNetData.Get(string.Format(GitJsonFileFormat, "RoleModulePermission"))));
129+
Console.WriteLine("Table:RoleModulePermission created success!");
130+
}
131+
else
132+
{
133+
Console.WriteLine("Table:RoleModulePermission already exists...");
134+
}
135+
#endregion
136+
137+
138+
#region Topic
139+
if (!await myContext.Db.Queryable<Topic>().AnyAsync())
140+
{
141+
myContext.GetEntityDB<Topic>().InsertRange(JsonHelper.ParseFormByJson<List<Topic>>(GetNetData.Get(string.Format(GitJsonFileFormat, "Topic"))));
142+
Console.WriteLine("Table:Topic created success!");
143+
}
144+
else
145+
{
146+
Console.WriteLine("Table:Topic already exists...");
147+
}
148+
#endregion
149+
150+
151+
#region TopicDetail
152+
if (!await myContext.Db.Queryable<TopicDetail>().AnyAsync())
153+
{
154+
myContext.GetEntityDB<TopicDetail>().InsertRange(JsonHelper.ParseFormByJson<List<TopicDetail>>(GetNetData.Get(string.Format(GitJsonFileFormat, "TopicDetail"))));
155+
Console.WriteLine("Table:TopicDetail created success!");
156+
}
157+
else
158+
{
159+
Console.WriteLine("Table:TopicDetail already exists...");
160+
}
161+
#endregion
162+
163+
164+
#region UserRole
165+
if (!await myContext.Db.Queryable<UserRole>().AnyAsync())
166+
{
167+
myContext.GetEntityDB<UserRole>().InsertRange(JsonHelper.ParseFormByJson<List<UserRole>>(GetNetData.Get(string.Format(GitJsonFileFormat, "UserRole"))));
168+
Console.WriteLine("Table:UserRole created success!");
169+
}
170+
else
171+
{
172+
Console.WriteLine("Table:UserRole already exists...");
173+
}
174+
#endregion
175+
176+
177+
#region sysUserInfo
178+
if (!await myContext.Db.Queryable<sysUserInfo>().AnyAsync())
179+
{
180+
myContext.GetEntityDB<sysUserInfo>().InsertRange(JsonHelper.ParseFormByJson<List<sysUserInfo>>(GetNetData.Get(string.Format(GitJsonFileFormat, "sysUserInfo"))));
181+
Console.WriteLine("Table:sysUserInfo created success!");
182+
}
183+
else
184+
{
185+
Console.WriteLine("Table:sysUserInfo already exists...");
186+
}
187+
#endregion
188+
189+
Console.WriteLine("Done seeding database.");
144190
}
145-
#endregion
146-
147-
148-
#region TopicDetail
149-
if (!await myContext.Db.Queryable<TopicDetail>().AnyAsync())
150-
{
151-
myContext.GetEntityDB<TopicDetail>().InsertRange(JsonHelper.ParseFormByJson<List<TopicDetail>>(GetNetData.Get(string.Format(GitJsonFileFormat, "TopicDetail"))));
152-
Console.WriteLine("Table:TopicDetail created success!");
153-
}
154-
else
155-
{
156-
Console.WriteLine("Table:TopicDetail already exists...");
157-
}
158-
#endregion
159-
160-
161-
#region UserRole
162-
if (!await myContext.Db.Queryable<UserRole>().AnyAsync())
163-
{
164-
myContext.GetEntityDB<UserRole>().InsertRange(JsonHelper.ParseFormByJson<List<UserRole>>(GetNetData.Get(string.Format(GitJsonFileFormat, "UserRole"))));
165-
Console.WriteLine("Table:UserRole created success!");
166-
}
167-
else
168-
{
169-
Console.WriteLine("Table:UserRole already exists...");
170-
}
171-
#endregion
172-
173-
174-
#region sysUserInfo
175-
if (!await myContext.Db.Queryable<sysUserInfo>().AnyAsync())
176-
{
177-
myContext.GetEntityDB<sysUserInfo>().InsertRange(JsonHelper.ParseFormByJson<List<sysUserInfo>>(GetNetData.Get(string.Format(GitJsonFileFormat, "sysUserInfo"))));
178-
Console.WriteLine("Table:sysUserInfo created success!");
179-
}
180-
else
181-
{
182-
Console.WriteLine("Table:sysUserInfo already exists...");
183-
}
184-
#endregion
185-
186191

187-
Console.WriteLine("Done seeding database.");
188192
Console.WriteLine();
189193

190194
}

Blog.Core.Tests/Controller_Test/BlogArticleController_Should.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ public async void AddEntity()
4141

4242
var res = await blogController.Post(blogArticle);
4343

44-
Assert.True(res.success);
44+
Assert.False(res.success);
4545

4646
var data = res.response;
4747

48-
Assert.NotNull(data);
48+
Assert.Null(data);
4949
}
5050
}
5151
}

0 commit comments

Comments
 (0)