Giter VIP home page Giter VIP logo

dotnet-core-boilerplate's Introduction

MyApplication - Boilerplate

MyApplication.Abstraction

MyApplication.Business

MyApplication.DataAccess

MyApplication.Endpoint

Open api end point for the application

BaseController

The base controller for all the apis that forces authorization and handles the AuthUser data in the pipeline

AccountController

implements the basic operations for account management

  • Task<OperationResult<ProfileResponse>> Profile()
  • Task<OperationResult<LoginResponse>> Login(LoginRequest request)
  • Task<OperationResult<RegisterResponse>> Register(RegisterRequest request)

StorageController

Implements the basic operation for uploading/downloading the objects from minio object storage

  • Task<OperationResult<StorageItemDto>> UploadPublic()
  • Task<OperationResult<StorageItemDto>> UploadProtected()
  • Task<IActionResult> DownloadPublic(string path)
  • Task<IActionResult> DownloadProtected(string path)

MyApplication.Workers

QueueListenerWorker

This is a base worker that will listen on a queue and will trigger when an item is pushed to it and ExecuteAction method will be called with the input type casted to the given input type if the process is successful the item will automatically acked from the queue if process fails item will be rejected and goes back to the queue Note: in real scenarios here we have to add a fail retry mechanism or something but it depends on the application business (you may need to process items in pushed order so you can not go to the next item)

AccountBackgroundWorker

This background worker is responsible to long running processes related to actions affecting an account, there might be a need to send an verification email or an otp...

MyApplication.Tests.Integration

The integration tests of each controller will be in a separate file

DatabaseSeed

This is a class holding variables that are used in the tests and also the OnSeedingDatabase will be executed before each test

EndpointIntegrationTestBase

EndpointIntegrationTestBase is a generic class that accepts a Startup, DatabaseSeed and a db context. it accepts a base url prefix and exposes the following methods:

  • Task<OperationResult<X>> GetJsonAsync<X>(string route)
  • Task<OperationResult<X>> PostJsonAsync<X>(string route, object payload)
  • Task AuthenticateClient(string? token = null) - this method will be used to set the token for the dispatching request
  • Task<string> OnGeneratingToken(T seedData) - this method will be called to generate the token that will attach to the header of dispatching request
  • Task OnSeedingDatabase(C dbContext, T seedData) - this method will run to seed the database, for example:
protected override async Task OnSeedingDatabase(ApplicationDbContext dbContext, DatabaseSeed seedData)
{
    await dbContext.Users.DeleteFromQueryAsync();
    await dbContext.Users.AddRangeAsync(seedData.Users);
    await dbContext.SaveChangesAsync();
}

AccountControllerTests

The integration tests for account controller

internal class AccountControllerTests :
    EndpointIntegrationTestBase<TestStartup, DatabaseSeed, ApplicationDbContext>,
    IAccountControllerIntegrationTests
{
    public AccountControllerTests() : base(EndpointConstants.Prefix)
    {
    }
}

it implements the IAccountControllerIntegrationTests interface

public interface IAccountControllerIntegrationTests
{
    Task Register_ShouldSucceed_UserDoesNotExists();
    Task Register_ShouldFail_UserDoesExists();
    Task Login_ShouldSucceed_CredentialsAreValid();
    Task Login_ShouldFail_CredentialsAreInvalid();
    Task GetProfile_ShouldSucceed_TokenIsValid();
}

MyApplication.Tests.Unit

AccountServiceTests

The unit tests for account service it implements the IAccountServiceTests interface

public interface IAccountServiceTests
{
    Task Register_ShouldSucceed_UserDoesNotExists();
    Task Register_ShouldFail_UserDoesExists();
    Task Login_ShouldSucceed_CredentialsAreValid();
    Task Login_ShouldFail_CredentialsAreInvalid();
    Task GetProfile_ShouldSucceed_TokenIsValid();
}

dotnet-core-boilerplate's People

Contributors

navid-kianfar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.