mirror of https://github.com/abpframework/abp.git
23 changed files with 344 additions and 66 deletions
@ -0,0 +1,18 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netcoreapp2.2</TargetFramework> |
|||
|
|||
<IsPackable>false</IsPackable> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\Volo.Blogging.EntityFrameworkCore.Tests\Volo.Blogging.EntityFrameworkCore.Tests.csproj" /> |
|||
<ProjectReference Include="..\Volo.Blogging.TestBase\Volo.Blogging.TestBase.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,11 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public abstract class BloggingDomainTestBase : BloggingTestBase<BloggingTestBaseModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
[DependsOn( |
|||
typeof(BloggingEntityFrameworkCoreTestModule), |
|||
typeof(BloggingTestBaseModule) |
|||
)] |
|||
public class BloggingDomainTestModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Shouldly; |
|||
using Volo.Blogging.Blogs; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class Blog_Tests |
|||
{ |
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetName(string name) |
|||
{ |
|||
var blog = new Blog(Guid.NewGuid(), "test blog", "test"); |
|||
blog.SetName(name); |
|||
blog.Name.ShouldBe(name); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetShortName(string name) |
|||
{ |
|||
var blog = new Blog(Guid.NewGuid(), "test blog", "test"); |
|||
blog.SetShortName(name); |
|||
blog.ShortName.ShouldBe(name); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Shouldly; |
|||
using Volo.Blogging.Comments; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class Comment_Tests |
|||
{ |
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetText(string text) |
|||
{ |
|||
var comment = new Comment(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "good"); |
|||
comment.SetText(text); |
|||
comment.Text.ShouldBe(text); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,65 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Shouldly; |
|||
using Volo.Blogging.Comments; |
|||
using Volo.Blogging.Posts; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class Post_Tests |
|||
{ |
|||
[Fact] |
|||
public void IncreaseReadCount() |
|||
{ |
|||
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
|||
post.IncreaseReadCount(); |
|||
post.ReadCount.ShouldBe(1); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetTitle(string title) |
|||
{ |
|||
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
|||
post.SetTitle(title); |
|||
post.Title.ShouldBe(title); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetUrl(string url) |
|||
{ |
|||
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
|||
post.SetUrl(url); |
|||
post.Url.ShouldBe(url); |
|||
} |
|||
|
|||
[Fact] |
|||
public void AddTag() |
|||
{ |
|||
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
|||
var tagId = Guid.NewGuid(); |
|||
post.AddTag(tagId); |
|||
post.Tags.ShouldContain(x => x.TagId == tagId); |
|||
} |
|||
|
|||
|
|||
[Fact] |
|||
public void RemoveTag() |
|||
{ |
|||
var post = new Post(Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid(), "abp", "⊙o⊙", "abp.io"); |
|||
var tagId = Guid.NewGuid(); |
|||
post.AddTag(tagId); |
|||
|
|||
post.Tags.ShouldContain(x => x.TagId == tagId); |
|||
|
|||
post.RemoveTag(tagId); |
|||
post.Tags.ShouldNotContain(x => x.TagId == tagId); |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Shouldly; |
|||
using Volo.Blogging.Tagging; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class Tag_Tests |
|||
{ |
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetName(string name) |
|||
{ |
|||
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag"); |
|||
tag.SetName(name); |
|||
tag.Name.ShouldBe(name); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(1)] |
|||
[InlineData(2)] |
|||
[InlineData(3)] |
|||
public void IncreaseUsageCount(int number) |
|||
{ |
|||
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag"); |
|||
tag.IncreaseUsageCount(number); |
|||
tag.UsageCount.ShouldBe(number); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData(1)] |
|||
[InlineData(2)] |
|||
[InlineData(3)] |
|||
public void DecreaseUsageCount(int number) |
|||
{ |
|||
var tag = new Tag(Guid.NewGuid(), "abp", 10, "abp tag"); |
|||
tag.DecreaseUsageCount(number); |
|||
tag.UsageCount.ShouldBe(10 - number); |
|||
} |
|||
|
|||
[Fact] |
|||
public void DecreaseUsageCount_Should_Greater_ThanOrEqual_Zero() |
|||
{ |
|||
var tag = new Tag(Guid.NewGuid(), "abp", 10, "abp tag"); |
|||
tag.DecreaseUsageCount(100); |
|||
tag.UsageCount.ShouldBe(0); |
|||
} |
|||
|
|||
[Theory] |
|||
[InlineData("aaa")] |
|||
[InlineData("bbb")] |
|||
public void SetDescription(string description) |
|||
{ |
|||
var tag = new Tag(Guid.NewGuid(), "abp", 0, "abp tag"); |
|||
tag.SetDescription(description); |
|||
tag.Description.ShouldBe(description); |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq.Expressions; |
|||
using System.Text; |
|||
using Shouldly; |
|||
using Volo.Abp.Users; |
|||
using Volo.Blogging.Users; |
|||
using Xunit; |
|||
|
|||
namespace Volo.Blogging |
|||
{ |
|||
public class BlogUser_Test |
|||
{ |
|||
[Fact] |
|||
public void Update() |
|||
{ |
|||
var userId = Guid.NewGuid(); |
|||
var tenantId = Guid.NewGuid(); |
|||
var blogUser = new BlogUser(new UserData(userId, "bob lee", "boblee@volosoft.com", "lee", "bob", true, |
|||
"123456", true, tenantId)); |
|||
var userData = new UserData(userId, "lee bob", "leebob@volosoft.com", "bob", "lee", false, |
|||
"654321", false, tenantId); |
|||
|
|||
blogUser.Update(userData); |
|||
|
|||
blogUser.Equals(new BlogUser(userData)).ShouldBeTrue(); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Update_User_Id_Must_Equals() |
|||
{ |
|||
var userId = Guid.NewGuid(); |
|||
var tenantId = Guid.NewGuid(); |
|||
var blogUser = new BlogUser(new UserData(userId, "bob lee", "boblee@volosoft.com", "lee", "bob", true, |
|||
"123456", true, tenantId)); |
|||
|
|||
var userData = new UserData(Guid.NewGuid(), "lee bob", "leebob@volosoft.com", "bob", "lee", false, |
|||
"654321", false, tenantId); |
|||
|
|||
Assert.Throws<ArgumentException>(() => blogUser.Update(userData)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void Update_Tenant_Id_Must_Equals() |
|||
{ |
|||
var userId = Guid.NewGuid(); |
|||
var tenantId = Guid.NewGuid(); |
|||
var blogUser = new BlogUser(new UserData(userId, "bob lee", "boblee@volosoft.com", "lee", "bob", true, |
|||
"123456", true, tenantId)); |
|||
|
|||
var userData = new UserData(userId, "lee bob", "leebob@volosoft.com", "bob", "lee", false, |
|||
"654321", false, Guid.NewGuid()); |
|||
|
|||
Assert.Throws<ArgumentException>(() => blogUser.Update(userData)); |
|||
} |
|||
|
|||
[Fact] |
|||
public void BlogUserEquals() |
|||
{ |
|||
var userId = Guid.NewGuid(); |
|||
var tenantId = Guid.NewGuid(); |
|||
var blogUser = new BlogUser(new UserData(userId, "bob lee", "john@volosoft.com", "lee", "bob", true, |
|||
"123456", true, tenantId)); |
|||
|
|||
var blogUser2= new BlogUser(new UserData(userId, "bob lee", "john@volosoft.com", "lee", "bob", true, |
|||
"123456", true, tenantId)); |
|||
|
|||
blogUser.Equals(blogUser2).ShouldBeTrue(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,9 +1,8 @@ |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
using Volo.Blogging.Blogs; |
|||
|
|||
namespace Volo.Blogging.Blogs |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class BlogRepository_Tests : BlogRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
using Volo.Blogging.Comments; |
|||
|
|||
namespace Volo.Blogging.Comments |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class CommentRepository_Tests : CommentRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
using Volo.Blogging.Posts; |
|||
|
|||
namespace Volo.Blogging.Posts |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class PostRepository_Tests : PostRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.EntityFrameworkCore; |
|||
using Volo.Blogging.Tagging; |
|||
|
|||
namespace Volo.Blogging.Tagging |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class TagRepository_Tests : TagRepository_Tests<BloggingEntityFrameworkCoreTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.Blogs; |
|||
using Volo.Blogging.Blogs; |
|||
|
|||
namespace Volo.Blogging.MongoDB |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class BlogRepository_Tests : BlogRepository_Tests<BloggingMongoDBTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.Comments; |
|||
using Volo.Blogging.Comments; |
|||
|
|||
namespace Volo.Blogging.MongoDB |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class CommentRepository_Tests : CommentRepository_Tests<BloggingMongoDBTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.Posts; |
|||
using Volo.Blogging.Posts; |
|||
|
|||
namespace Volo.Blogging.MongoDB.Tests.Volo.Blogging.Posts |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class PostRepository_Tests : PostRepository_Tests<BloggingMongoDBTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -1,12 +1,8 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
using Volo.Blogging.Tagging; |
|||
using Volo.Blogging.Tagging; |
|||
|
|||
namespace Volo.Blogging.MongoDB |
|||
namespace Volo.Blogging |
|||
{ |
|||
public class TagRepository_Tests : TagRepository_Tests<BloggingMongoDBTestModule> |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue