diff --git a/docs/en/Tutorials/Part-10.md b/docs/en/Tutorials/Part-10.md index e71beccd6f..d06cea6b6e 100644 --- a/docs/en/Tutorials/Part-10.md +++ b/docs/en/Tutorials/Part-10.md @@ -614,19 +614,19 @@ using System.Threading.Tasks; using Acme.BookStore.Authors; using Shouldly; using Volo.Abp.Application.Dtos; +using Volo.Abp.Modularity; using Volo.Abp.Validation; using Xunit; namespace Acme.BookStore.Books; - {{if DB=="Mongo"}} -[Collection(BookStoreTestConsts.CollectionDefinitionName)]{{end}} -public class BookAppService_Tests : BookStoreApplicationTestBase +public abstract class BookAppService_Tests : BookStoreApplicationTestBase + where TStartupModule : IAbpModule { private readonly IBookAppService _bookAppService; private readonly IAuthorAppService _authorAppService; - public BookAppService_Tests() + protected BookAppService_Tests() { _bookAppService = GetRequiredService(); _authorAppService = GetRequiredService(); @@ -643,7 +643,7 @@ public class BookAppService_Tests : BookStoreApplicationTestBase //Assert result.TotalCount.ShouldBeGreaterThan(0); result.Items.ShouldContain(b => b.Name == "1984" && - b.AuthorName == "George Orwell"); + b.AuthorName == "George Orwell"); } [Fact] diff --git a/docs/en/Tutorials/Part-4.md b/docs/en/Tutorials/Part-4.md index 072392e82b..c97bce6bd7 100644 --- a/docs/en/Tutorials/Part-4.md +++ b/docs/en/Tutorials/Part-4.md @@ -82,19 +82,18 @@ using System.Linq; using System.Threading.Tasks; using Shouldly; using Volo.Abp.Application.Dtos; +using Volo.Abp.Modularity; using Volo.Abp.Validation; using Xunit; namespace Acme.BookStore.Books; -{{if DB=="Mongo"}} -[Collection(BookStoreTestConsts.CollectionDefinitionName)] -{{end}} -public class BookAppService_Tests : BookStoreApplicationTestBase +public abstract class BookAppService_Tests : BookStoreApplicationTestBase + where TStartupModule : IAbpModule { private readonly IBookAppService _bookAppService; - public BookAppService_Tests() + protected BookAppService_Tests() { _bookAppService = GetRequiredService(); } @@ -114,6 +113,41 @@ public class BookAppService_Tests : BookStoreApplicationTestBase } ```` +{{if DB == "EF"}} +Add a new implementation class of `BookAppService_Tests` class, named `EfCoreBookAppService_Tests` in the `EntityFrameworkCore\Applications\Books` namespace (folder) of the `Acme.BookStore.EntityFrameworkCore.Tests` project: + +````csharp +using Acme.BookStore.Books; +using Xunit; + +namespace Acme.BookStore.EntityFrameworkCore.Applications.Books; + +[Collection(BookStoreTestConsts.CollectionDefinitionName)] +public class EfCoreBookAppService_Tests : BookAppService_Tests +{ + +} +```` +{{end}} + +{{if DB == "Mongo"}} +Add a new implementation class of `BookAppService_Tests` class, named `MongoDBBookAppService_Tests` in the `MongoDb\Applications\Books` namespace (folder) of the `Acme.BookStore.MongoDB.Tests` project: + +````csharp +using Acme.BookStore.MongoDB; +using Acme.BookStore.Books; +using Xunit; + +namespace Acme.BookStore.MongoDb.Applications.Books; + +[Collection(BookStoreTestConsts.CollectionDefinitionName)] +public class MongoDBBookAppService_Tests : BookAppService_Tests +{ + +} +```` +{{end}} + * `Should_Get_List_Of_Books` test simply uses `BookAppService.GetListAsync` method to get and check the list of books. * We can safely check the book "1984" by its name, because we know that this books is available in the database since we've added it in the seed data. @@ -174,19 +208,18 @@ using System.Linq; using System.Threading.Tasks; using Shouldly; using Volo.Abp.Application.Dtos; +using Volo.Abp.Modularity; using Volo.Abp.Validation; using Xunit; namespace Acme.BookStore.Books; -{{if DB=="Mongo"}} -[Collection(BookStoreTestConsts.CollectionDefinitionName)] -{{end}} -public class BookAppService_Tests : BookStoreApplicationTestBase +public abstract class BookAppService_Tests : BookStoreApplicationTestBase + where TStartupModule : IAbpModule { private readonly IBookAppService _bookAppService; - public BookAppService_Tests() + protected BookAppService_Tests() { _bookAppService = GetRequiredService(); } @@ -203,7 +236,7 @@ public class BookAppService_Tests : BookStoreApplicationTestBase result.TotalCount.ShouldBeGreaterThan(0); result.Items.ShouldContain(b => b.Name == "1984"); } - + [Fact] public async Task Should_Create_A_Valid_Book() { diff --git a/docs/en/Tutorials/Part-8.md b/docs/en/Tutorials/Part-8.md index 9d638e909e..7ea3c6cbae 100644 --- a/docs/en/Tutorials/Part-8.md +++ b/docs/en/Tutorials/Part-8.md @@ -481,18 +481,17 @@ Finally, we can write some tests for the `IAuthorAppService`. Add a new class, n using System; using System.Threading.Tasks; using Shouldly; +using Volo.Abp.Modularity; using Xunit; namespace Acme.BookStore.Authors; - {{if DB=="Mongo"}} -[Collection(BookStoreTestConsts.CollectionDefinitionName)] -{{end}} -public class AuthorAppService_Tests : BookStoreApplicationTestBase +public abstract class AuthorAppService_Tests : BookStoreApplicationTestBase + where TStartupModule : IAbpModule { private readonly IAuthorAppService _authorAppService; - public AuthorAppService_Tests() + protected AuthorAppService_Tests() { _authorAppService = GetRequiredService(); } @@ -554,6 +553,41 @@ public class AuthorAppService_Tests : BookStoreApplicationTestBase } ```` +{{if DB == "EF"}} +Add a new implementation class of `AuthorAppService_Tests` class, named `EfCoreAuthorAppService_Tests` in the `EntityFrameworkCore\Applications\Authors` namespace (folder) of the `Acme.BookStore.EntityFrameworkCore.Tests` project: + +````csharp +using Acme.BookStore.Authors; +using Xunit; + +namespace Acme.BookStore.EntityFrameworkCore.Applications.Authors; + +[Collection(BookStoreTestConsts.CollectionDefinitionName)] +public class EfCoreAuthorAppService_Tests : AuthorAppService_Tests +{ + +} +```` +{{end}} + +{{if DB == "Mongo"}} +Add a new implementation class of `AuthorAppService_Tests` class, named `MongoDBAuthorAppService_Tests` in the `MongoDb\Applications\Authors` namespace (folder) of the `Acme.BookStore.MongoDB.Tests` project: + +````csharp +using Acme.BookStore.MongoDB; +using Acme.BookStore.Authors; +using Xunit; + +namespace Acme.BookStore.MongoDb.Applications.Authors; + +[Collection(BookStoreTestConsts.CollectionDefinitionName)] +public class MongoDBAuthorAppService_Tests : AuthorAppService_Tests +{ + +} +```` +{{end}} + Created some tests for the application service methods, which should be clear to understand. ## The Next Part