-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
shuhan jin #5
Conversation
…to articleRepository
There was a problem hiding this 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) |
There was a problem hiding this comment.
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>()); |
There was a problem hiding this comment.
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 => |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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!; |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
No description provided.