Esempio n. 1
0
        public async Task SetUp()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "userServiceTestDb").Options;

            this.dbContext = new ApplicationDbContext(options);
            await this.dbContext.Database.EnsureDeletedAsync();

            var userRepository = new EfDeletableEntityRepository <ApplicationUser>(this.dbContext);

            this.cloudinaryService = new FakeCloudinary();
            this.userService       = new UserService(userRepository, cloudinaryService);
        }
Esempio n. 2
0
        public async Task SetUp()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "CategoryTestDb").Options;

            this.dbContext = new ApplicationDbContext(options);
            await this.dbContext.Database.EnsureCreatedAsync();

            var categoryRepo   = new EfDeletableEntityRepository <Category>(this.dbContext);
            var fakeCloudinary = new FakeCloudinary();

            this.categoryService = new CategoryService(categoryRepo, fakeCloudinary);
        }
Esempio n. 3
0
        public async Task SetUp()
        {
            //AutoMapperConfig.RegisterMappings(typeof(TestPostClass).Assembly);

            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "PostsTestDb").Options;

            this.dbContext = new ApplicationDbContext(options);
            var categoryRepository     = new EfDeletableEntityRepository <Category>(this.dbContext);
            var postRepository         = new EfDeletableEntityRepository <Post>(this.dbContext);
            var userPostVoteRepository = new EfDeletableEntityRepository <UserPostVote>(this.dbContext);
            var postTagRepository      = new EfRepository <PostTag>(this.dbContext);
            var tagRepository          = new EfDeletableEntityRepository <Tag>(this.dbContext);

            var tagService        = new TagService(tagRepository);
            var cloudinaryService = new FakeCloudinary();
            var categoryService   = new CategoryService(categoryRepository, cloudinaryService);

            this.postsService = new PostsService(
                postRepository,
                userPostVoteRepository,
                postTagRepository,
                categoryService,
                cloudinaryService,
                tagService);

            await this.dbContext.Database.EnsureCreatedAsync();

            var user1 = new ApplicationUser()
            {
                Id       = "userId1",
                UserName = "******",
            };

            var user2 = new ApplicationUser()
            {
                Id       = "userId2",
                UserName = "******",
            };

            await this.dbContext.Users.AddAsync(user1);

            await this.dbContext.Users.AddAsync(user2);

            await this.dbContext.SaveChangesAsync();
        }