public UserController( BlogsDataBaseContext context, IMapper mapper, UserManager <User> userManager, ILogger <UserController> logger) : base(context, mapper, logger) { this.userManager = userManager; }
public ControllerCommon( BlogsDataBaseContext context, IMapper mapper, ILogger <T> logger) { this.context = context; this.mapper = mapper; this.logger = logger; }
public AuthenticationController( BlogsDataBaseContext context, IMapper mapper, UserManager <User> userManager, ITokenService tokenService, ILogger <AuthenticationController> logger) : base(context, mapper, logger) { this.userManager = userManager; this.tokenService = tokenService; }
public static DbContextOptions <BlogsDataBaseContext> CreateInMemoryDatabase() { var options = new DbContextOptionsBuilder <BlogsDataBaseContext>() .UseInMemoryDatabase(databaseName: "Mock DB") .Options; // setup using (var ctx = new BlogsDataBaseContext(options)) AddItems(ctx); return(options); }
public static void AddItems(BlogsDataBaseContext ctx) { ctx.BlogPosts.Add( new BlogPost() { BlogId = blogId, BlogPostId = postId, BodyText = postText, HeaderText = postHeader, Comments = new List <Comment>() }); ctx.SaveChanges(); }
public async Task TestGetExistingBlogPost() { var options = DbCreator.CreateInMemoryDatabase(); var loggerMock = new Mock <ILogger <BlogPostsController> >(); var mapper = TestMapper.CreateMapper(); FullBlogPost post; using (var ctx = new BlogsDataBaseContext(options)) { var controller = new BlogPostsController(ctx, mapper, loggerMock.Object); // act var result = await controller.GetBlogPost(1); post = result.Value; } // check Assert.NotNull(post); Assert.Equal(DbCreator.postText, post.BodyText); Assert.Equal(DbCreator.postHeader, post.HeaderText); }