Esempio n. 1
0
        public UnitOfWork(
            ApplicationDbContext context,
            UserManager <User> userManager,
            SignInManager <User> signInManager,
            IPasswordHasher <User> passwordHasher
            )
        {
            _context        = context;
            _userManager    = userManager;
            _signInManager  = signInManager;
            _passwordHasher = passwordHasher;

            ContactRepository      = new EfCoreContactRepository(_context);
            PostCategoryRepository = new EfCorePostCategoryRepository(_context);
            PostCommentRepository  = new EfCorePostCommentRepository(_context);
            PostRepository         = new EfCorePostRepository(_context);
            SettingRepository      = new EfCoreSettingRepository(_context);
            UserRepository         = new EfCoreUserRepository(_userManager, _signInManager, _passwordHasher);
        }
Esempio n. 2
0
        public void Setup()
        {
            _data = new List <PostComment>()
            {
                new PostComment()
                {
                    Id           = 1,
                    ParentId     = null,
                    Status       = PostCommentStatus.Accepted,
                    User         = new User(),
                    Post         = new Post(),
                    UserId       = null,
                    UserFullName = "UserFullName",
                    Email        = "Email",
                    Body         = "Body",
                    Ip           = "Ip"
                },
                new PostComment()
                {
                    Id           = 2,
                    ParentId     = 1,
                    Status       = PostCommentStatus.Unclear,
                    User         = new User(),
                    Post         = new Post(),
                    UserId       = null,
                    UserFullName = "UserFullName",
                    Email        = "Email",
                    Body         = "Body",
                    Ip           = "Ip"
                },
                new PostComment()
                {
                    Id           = 3,
                    ParentId     = 1,
                    Status       = PostCommentStatus.Accepted,
                    User         = new User(),
                    Post         = new Post(),
                    UserId       = null,
                    UserFullName = "UserFullName",
                    Email        = "Email",
                    Body         = "Body",
                    Ip           = "Ip"
                },
                new PostComment()
                {
                    Id           = 4,
                    ParentId     = 1,
                    Status       = PostCommentStatus.Unclear,
                    User         = new User(),
                    Post         = new Post(),
                    UserId       = null,
                    UserFullName = "UserFullName",
                    Email        = "Email",
                    Body         = "Body",
                    Ip           = "Ip"
                },
                new PostComment()
                {
                    Id           = 5,
                    ParentId     = 1,
                    Status       = PostCommentStatus.Rejected,
                    User         = new User(),
                    Post         = new Post(),
                    UserId       = null,
                    UserFullName = "UserFullName",
                    Email        = "Email",
                    Body         = "Body",
                    Ip           = "Ip"
                }
            };

            _context = InMemoryDatabaseUtility.GetInMemoryDatabaseContext();

            _context.PostComments.AddRange(_data);
            _context.SaveChanges();

            _repository = new EfCorePostCommentRepository(_context);
        }