Skip to content

Conversation

@celianiu
Copy link

@celianiu celianiu commented Nov 7, 2023

Sorry for single commit message; Forget to fork to my own repo

@celianiu
Copy link
Author

celianiu commented Nov 8, 2023

image

private readonly IArticleRepository articleRepository = null;
private readonly IUserRepository userRepository = null;

public ArticleService(ArticleStore articleStore, UserStore userStore, IArticleRepository articleRepository, IUserRepository userRepository)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job: dependency injection

string articleTitle = "Good day";

Article article = new Article(userNameWhoWillAdd, articleTitle, articleContent);
User newUser = new User(userNameWhoWillAdd);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good mock.

@jingwang315
Copy link

Good points:

  1. Use DI container to register all single and scoped dependencies.
  2. Apart from UserController test, all required test passed.
  3. 3 layers of controller.
  4. Commit step by step.
  5. Readable commit message

public ArticleController(ArticleService articleService)
public ArticleController(ArticleStore articleStore, UserStore userStore, UserService userService, ArticleService articleService)
{
//this.articleStore = articleStore;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: remove dead code

public async Task<List<Article>> ListAsync()
{
return await articleService.GetAll();
Console.WriteLine(articleService.GetAllAsync());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: remove code for debug

{
private readonly ArticleStore articleStore = null!;
private readonly UserStore userStore = null!;
private readonly ArticleService articleService = null!;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: remove unused articleService


namespace MiniBlog.Repositories
{
public class UserRepository : IUserRepository

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well: nice to also provide repository for user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants