parent
c356dd7a31
commit
9c3b0c5d98
@ -1,179 +0,0 @@ |
|||||||
using Autofac; |
|
||||||
using Tiobon.Core.Controllers; |
|
||||||
using Tiobon.Core.IServices; |
|
||||||
using Tiobon.Core.Model; |
|
||||||
using Tiobon.Core.Model.Models; |
|
||||||
using Tiobon.Core.Model.ViewModels; |
|
||||||
using Microsoft.Extensions.Logging; |
|
||||||
using Moq; |
|
||||||
using System; |
|
||||||
using System.Collections.Generic; |
|
||||||
using Xunit; |
|
||||||
|
|
||||||
namespace Tiobon.Core.Tests |
|
||||||
{ |
|
||||||
public class TiobonController_Should |
|
||||||
{ |
|
||||||
Mock<ITiobonArticleServices> mockTiobonSev = new Mock<ITiobonArticleServices>(); |
|
||||||
Mock<ILogger<TiobonController>> mockLogger = new Mock<ILogger<TiobonController>>(); |
|
||||||
TiobonController TiobonController; |
|
||||||
|
|
||||||
private ITiobonArticleServices TiobonArticleServices; |
|
||||||
DI_Test dI_Test = new DI_Test(); |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public TiobonController_Should() |
|
||||||
{ |
|
||||||
mockTiobonSev.Setup(r => r.Query()); |
|
||||||
|
|
||||||
var container = dI_Test.DICollections(); |
|
||||||
TiobonArticleServices = container.Resolve<ITiobonArticleServices>(); |
|
||||||
TiobonController = new TiobonController(mockLogger.Object); |
|
||||||
TiobonController._TiobonArticleServices = TiobonArticleServices; |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public void TestEntity() |
|
||||||
{ |
|
||||||
TiobonArticle TiobonArticle = new TiobonArticle(); |
|
||||||
|
|
||||||
Assert.True(TiobonArticle.bID >= 0); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Tiobon_Page_Test() |
|
||||||
{ |
|
||||||
ServiceResult<PageModel<TiobonArticle>> Tiobons = await TiobonController.Get(1, 1, "技术博文", ""); |
|
||||||
Assert.NotNull(Tiobons); |
|
||||||
Assert.NotNull(Tiobons.Data); |
|
||||||
Assert.True(Tiobons.Data.dataCount >= 0); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Tiobon_Test() |
|
||||||
{ |
|
||||||
ServiceResult<TiobonViewModels> TiobonVo = await TiobonController.Get(1.ObjToLong()); |
|
||||||
|
|
||||||
Assert.NotNull(TiobonVo); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Tiobon_For_Nuxt_Test() |
|
||||||
{ |
|
||||||
ServiceResult<TiobonViewModels> TiobonVo = await TiobonController.DetailNuxtNoPer(1); |
|
||||||
|
|
||||||
Assert.NotNull(TiobonVo); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Go_Url_Test() |
|
||||||
{ |
|
||||||
object urlAction = await TiobonController.GoUrl(1); |
|
||||||
|
|
||||||
Assert.NotNull(urlAction); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Tiobon_By_Type_For_MVP_Test() |
|
||||||
{ |
|
||||||
ServiceResult<List<TiobonArticle>> Tiobons = await TiobonController.GetTiobonsByTypesForMVP("技术博文"); |
|
||||||
|
|
||||||
Assert.NotNull(Tiobons); |
|
||||||
Assert.True(Tiobons.Success); |
|
||||||
Assert.NotNull(Tiobons.Data); |
|
||||||
Assert.True(Tiobons.Data.Count >= 0); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Tiobon_By_Id_For_MVP_Test() |
|
||||||
{ |
|
||||||
ServiceResult<TiobonArticle> Tiobon = await TiobonController.GetTiobonByIdForMVP(1); |
|
||||||
|
|
||||||
Assert.NotNull(Tiobon); |
|
||||||
Assert.True(Tiobon.Success); |
|
||||||
Assert.NotNull(Tiobon.Data); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void PostTest() |
|
||||||
{ |
|
||||||
TiobonArticle TiobonArticle = new TiobonArticle() |
|
||||||
{ |
|
||||||
bCreateTime = DateTime.Now, |
|
||||||
bUpdateTime = DateTime.Now, |
|
||||||
btitle = "xuint :test controller addEntity", |
|
||||||
bcontent = "xuint :test controller addEntity. this is content.this is content." |
|
||||||
}; |
|
||||||
|
|
||||||
var res = await TiobonController.Post(TiobonArticle); |
|
||||||
|
|
||||||
Assert.True(res.Success); |
|
||||||
|
|
||||||
var data = res.Data; |
|
||||||
|
|
||||||
Assert.NotNull(data); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Post_Insert_For_MVP_Test() |
|
||||||
{ |
|
||||||
TiobonArticle TiobonArticle = new TiobonArticle() |
|
||||||
{ |
|
||||||
bCreateTime = DateTime.Now, |
|
||||||
bUpdateTime = DateTime.Now, |
|
||||||
btitle = "xuint :test controller addEntity", |
|
||||||
bcontent = "xuint :test controller addEntity. this is content.this is content." |
|
||||||
}; |
|
||||||
|
|
||||||
var res = await TiobonController.AddForMVP(TiobonArticle); |
|
||||||
|
|
||||||
Assert.True(res.Success); |
|
||||||
|
|
||||||
var data = res.Data; |
|
||||||
|
|
||||||
Assert.NotNull(data); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Put_Test() |
|
||||||
{ |
|
||||||
TiobonArticle TiobonArticle = new TiobonArticle() |
|
||||||
{ |
|
||||||
bID = 1, |
|
||||||
bCreateTime = DateTime.Now, |
|
||||||
bUpdateTime = DateTime.Now, |
|
||||||
btitle = "xuint put :test controller addEntity", |
|
||||||
bcontent = "xuint put :test controller addEntity. this is content.this is content." |
|
||||||
}; |
|
||||||
|
|
||||||
var res = await TiobonController.Put(TiobonArticle); |
|
||||||
|
|
||||||
Assert.True(res.Success); |
|
||||||
|
|
||||||
var data = res.Data; |
|
||||||
|
|
||||||
Assert.NotNull(data); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Delete_Test() |
|
||||||
{ |
|
||||||
var res = await TiobonController.Delete(99); |
|
||||||
|
|
||||||
Assert.False(res.Success); |
|
||||||
|
|
||||||
var data = res.Data; |
|
||||||
|
|
||||||
Assert.Null(data); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Apache_Update_Test() |
|
||||||
{ |
|
||||||
var res = await TiobonController.ApacheTestUpdate(); |
|
||||||
|
|
||||||
Assert.True(res.Success); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,74 +0,0 @@ |
|||||||
using Tiobon.Core.IServices; |
|
||||||
using Tiobon.Core.Model.Models; |
|
||||||
using Xunit; |
|
||||||
using System; |
|
||||||
using System.Linq; |
|
||||||
using Autofac; |
|
||||||
|
|
||||||
namespace Tiobon.Core.Tests |
|
||||||
{ |
|
||||||
public class TiobonArticleService_Should |
|
||||||
{ |
|
||||||
|
|
||||||
private ITiobonArticleServices TiobonArticleServices; |
|
||||||
DI_Test dI_Test = new DI_Test(); |
|
||||||
|
|
||||||
|
|
||||||
public TiobonArticleService_Should() |
|
||||||
{ |
|
||||||
//mockTiobonRep.Setup(r => r.Query()); |
|
||||||
|
|
||||||
var container = dI_Test.DICollections(); |
|
||||||
|
|
||||||
TiobonArticleServices = container.Resolve<ITiobonArticleServices>(); |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[Fact] |
|
||||||
public void TiobonArticleServices_Test() |
|
||||||
{ |
|
||||||
Assert.NotNull(TiobonArticleServices); |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Get_Tiobons_Test() |
|
||||||
{ |
|
||||||
var data = await TiobonArticleServices.GetTiobons(); |
|
||||||
|
|
||||||
Assert.True(data.Any()); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Add_Tiobon_Test() |
|
||||||
{ |
|
||||||
TiobonArticle TiobonArticle = new TiobonArticle() |
|
||||||
{ |
|
||||||
bCreateTime = DateTime.Now, |
|
||||||
bUpdateTime = DateTime.Now, |
|
||||||
btitle = "xuint test title", |
|
||||||
bcontent = "xuint test content", |
|
||||||
bsubmitter = "xuint test submitter", |
|
||||||
}; |
|
||||||
|
|
||||||
var BId = await TiobonArticleServices.Add(TiobonArticle); |
|
||||||
|
|
||||||
Assert.True(BId > 0); |
|
||||||
} |
|
||||||
|
|
||||||
[Fact] |
|
||||||
public async void Delete_Tiobon_Test() |
|
||||||
{ |
|
||||||
Add_Tiobon_Test(); |
|
||||||
|
|
||||||
var deleteModel = (await TiobonArticleServices.Query(d => d.btitle == "xuint test title")).FirstOrDefault(); |
|
||||||
|
|
||||||
Assert.NotNull(deleteModel); |
|
||||||
|
|
||||||
var IsDel = await TiobonArticleServices.Delete(deleteModel); |
|
||||||
|
|
||||||
Assert.True(IsDel); |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
Loading…
Reference in new issue