Example #1
0
        public static void InitThreeUsersWhereLastOneIsDeleted(InTouchContext context)
        {
            var users = new User[]
            {
                new User
                {
                    FirstName = "admin",
                    LastName  = "admin",
                    Email     = "*****@*****.**",
                    IsDeleted = false
                },
                new User
                {
                    FirstName = "user",
                    LastName  = "user",
                    Email     = "*****@*****.**",
                    IsDeleted = false
                },
                new User
                {
                    FirstName = "deleted",
                    LastName  = "deleted",
                    Email     = "deletedgmail.com",
                    IsDeleted = true
                }
            };

            foreach (var user in users)
            {
                context.Users.Add(user);
            }

            context.SaveChanges();
        }
Example #2
0
        public static void Init6UsersWhereLastOneIsDeleted(InTouchContext context)
        {
            var users = new List <User>();

            for (int i = 0; i < 5; i++)
            {
                users.Add(
                    new User
                {
                    FirstName = "user" + i,
                    LastName  = "user" + i,
                    Email     = "*****@*****.**" + i,
                    IsDeleted = false,
                });
            }

            users.Add(new User
            {
                FirstName = "deleted",
                LastName  = "deleted",
                Email     = "deletedgmail.com",
                IsDeleted = true,
            });

            foreach (var user in users)
            {
                context.Users.Add(user);
            }

            context.SaveChanges();
        }
Example #3
0
 public UserRepositoryTest(DatabaseFixture fixture)
 {
     _fixture        = fixture;
     _context        = _fixture.CreateContext();
     _userRepository = new UserRepository(_context);
     TestDataInitializer.ClearData(_context);
 }
Example #4
0
        public static void ClearData(InTouchContext context)
        {
            context.Posts.RemoveRange(context.Posts);
            context.SaveChanges();

            context.Users.RemoveRange(context.Users);
            context.SaveChanges();
        }
Example #5
0
        public async static Task Init5PostsWith1DeletedPost(InTouchContext context, User user)
        {
            //var user1 = await InitOneGeneralUserAsync(context);

            var posts = new Post[]
            {
                new Post
                {
                    Content     = "Content1",
                    CreatedDate = DateTime.Now,
                    IsDeleted   = false,
                    IsPublic    = true,
                    Title       = "Title1",
                    UserId      = user.Id
                },
                new Post
                {
                    Content     = "Content2",
                    CreatedDate = DateTime.Now,
                    IsDeleted   = false,
                    IsPublic    = true,
                    Title       = "Title2",
                    UserId      = user.Id
                },
                new Post {
                    Content     = "Content3",
                    CreatedDate = DateTime.Now,
                    IsDeleted   = false,
                    IsPublic    = true,
                    Title       = "Title3",
                    UserId      = user.Id
                },
                new Post {
                    Content     = "Content4",
                    CreatedDate = DateTime.Now,
                    IsDeleted   = false,
                    IsPublic    = true,
                    Title       = "Title4",
                    UserId      = user.Id
                },
                new Post {
                    Content     = "Deleted",
                    CreatedDate = DateTime.Now,
                    IsDeleted   = true,
                    IsPublic    = true,
                    Title       = "Deleted",
                    UserId      = user.Id
                }
            };

            foreach (var post in posts)
            {
                context.Posts.Add(post);
            }

            context.SaveChanges();
        }
Example #6
0
 public static async Task Init_3HP_3NP_Posts(InTouchContext context)
 {
     await Init_1Post(context, "NH", 8, PostPriority.High);
     await Init_1Post(context, "N", 5, PostPriority.Normal);
     await Init_1Post(context, "3", 10, PostPriority.Normal);
     await Init_1Post(context, "2", 20, PostPriority.Normal);
     await Init_1Post(context, "1", 30, PostPriority.Normal);
     await Init_1Post(context, "OH", 100, PostPriority.High);
 }
Example #7
0
        public async static Task <User> InitOneDeletedUserAsync(InTouchContext context)
        {
            var userToAdd = context.Users.Add(new User
            {
                FirstName = "deleted",
                LastName  = "deleted",
                Email     = "*****@*****.**",
                IsDeleted = true,
            });

            context.SaveChanges();

            var user = await context.Users.LastOrDefaultAsync();

            return(user);
        }
Example #8
0
        public async static Task <User> InitOneGeneralUserAsync(InTouchContext context)
        {
            var userToAdd = context.Users.Add(new User
            {
                FirstName = "admin",
                LastName  = "admin",
                Email     = Guid.NewGuid() + "@m.c",
                IsDeleted = false,
                RoleId    = 2
            });

            context.SaveChanges();

            var user = await context.Users.LastOrDefaultAsync();

            return(user);
        }
Example #9
0
        public async static Task <Post> InitOneDeletedPostAsync(InTouchContext context)
        {
            var user1 = await InitOneGeneralUserAsync(context);

            var postToAdd = context.Posts.Add(
                new Post
            {
                Content     = "Content1",
                CreatedDate = DateTime.Now,
                IsDeleted   = true,
                IsPublic    = true,
                Title       = "Title1",
                UserId      = user1.Id
            });

            context.SaveChanges();

            var post = await context.Posts.LastOrDefaultAsync();

            return(post);
        }
Example #10
0
        public PostServiceIntegrationTest(DatabaseFixture fixture)
        {
            _fixture        = fixture;
            _context        = _fixture.CreateContext();
            _postRepository = new PostRepository(_context);
            TestDataInitializer.ClearData(_context);

            _unitOfWork      = new Mock <IUnitOfWork>();
            _userContextMock = new Mock <IUserContext>();
            _fileServiceMock = new Mock <IFileService>();
            _commentService  = new Mock <ICommentService>();
            _postOptions     = new Mock <IOptionsSnapshot <PostConfig> >();
            _batchOptions    = new Mock <IOptionsSnapshot <FullscreenBatchConfig> >();

            _postService = new PostService(_unitOfWork.Object, _fileServiceMock.Object, _commentService.Object, _userContextMock.Object,
                                           _batchOptions.Object, _postOptions.Object);
            _unitOfWork.SetupGet(x => x.Posts).Returns(_postRepository);

            _batchOptions.SetupProperty(bo => bo.Value.FullscreenBatchSize, 4);

            //_batchOptions.Object.Value.FullscreenBatchSize = 4;
        }
Example #11
0
        public static async Task Init_1Post(
            InTouchContext context, string title,
            int daysOld, PostPriority priority)
        {
            daysOld *= -1;

            var user = await InitOneGeneralUserAsync(context);

            var post = new Post
            {
                Content       = "Content1",
                CreatedDate   = DateTime.Now.AddDays(daysOld),
                IsDeleted     = false,
                IsPublic      = true,
                Title         = title,
                UserId        = user.Id,
                Priority      = priority,
                StartDateTime = DateTime.Now.AddDays(daysOld),
                EndDateTime   = DateTime.Now.AddDays(Math.Abs(daysOld) + 50),
            };

            context.Posts.Add(post);
            context.SaveChanges();
        }
Example #12
0
 public UserRepository(InTouchContext context)
 {
     this.db = context;
 }
Example #13
0
 public LikeRepository(InTouchContext db)
 {
     _db = db;
 }
Example #14
0
 public CommentRepository(InTouchContext context)
 {
     db = context;
 }
Example #15
0
 public PostRepository(InTouchContext context)
 {
     db = context;
 }
Example #16
0
 public EFUnitOfWork(InTouchContext db)
 {
     this.db = db;
 }
Example #17
0
 public FileRepository(InTouchContext dbContext)
 {
     _db = dbContext;
 }
Example #18
0
 public RoleRepository(InTouchContext context)
 {
     this.db = context;
 }
Example #19
0
 public DatabaseInitializer(InTouchContext dbContext)
 {
     _dbContext = dbContext;
 }