Skip to content

shuhan jin #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

shuhan jin #5

wants to merge 6 commits into from

Conversation

sjin9
Copy link

@sjin9 sjin9 commented Nov 7, 2023

No description provided.

Copy link

@lklgithub lklgithub left a comment

Choose a reason for hiding this comment

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

well:
commit messages are very clear and easy to understand
good code logic

need to better
add some test cases, and fix test cases


public ArticleService(ArticleStore articleStore, UserStore userStore, IArticleRepository articleRepository)
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.

maybe not need ArticleStore and UserStore class

string userNameWhoWillAdd = "Tom";
string articleContent = "What a good day today!";
string articleTitle = "Good day";
Article article = new Article(userNameWhoWillAdd, articleTitle, articleContent);

var userStore = new UserStore(new List<User>());

Choose a reason for hiding this comment

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

suggest code line from 68 to70 move to constructor

@@ -18,7 +18,7 @@ public TestBase(CustomWebApplicationFactory<Startup> factory)

protected CustomWebApplicationFactory<Startup> Factory { get; }

protected HttpClient GetClient(ArticleStore articleStore = null, UserStore userStore = null, IArticleRepository articleRepository = null)
protected HttpClient GetClient(ArticleStore articleStore = null, UserStore userStore = null, IArticleRepository articleRepository = null, IUserRepository userRepository = null)
{
return Factory.WithWebHostBuilder(builder =>

Choose a reason for hiding this comment

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

suggest add this code in line 37:
services.AddScoped();
services.AddScoped(provider =>
{
return articleRepository;
});
services.AddScoped(provider =>
{
return userRepository;
});


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 implement repository for user

@@ -13,38 +13,50 @@ public class ArticleService
private readonly ArticleStore articleStore = null!;

Choose a reason for hiding this comment

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

suggestion: remove unused variable like articleStore & userStore

}

/*public async Task<Article?> CreateArticle(Article article)

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<User> GetByName(string username)
=> await userRepository.GetByName(username);

Choose a reason for hiding this comment

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

well: nice to lambda expression

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