Beispiel #1
0
        public void DbContext_GetWhereImageNotExists()
        {
            var ctx = new UserContext();

            // Tests
            var shopRepository = new UserRepository(ctx);

            Assert.AreEqual(shopRepository.GetWhereImageNotExists().Count, 2);
        }
Beispiel #2
0
        public void DbContext_GetAllUsers()
        {
            var ctx = new UserContext();
            // Create Fake user Data, this will replace our Database entries.
            var userList = new List<User>
            {
                new User() { Id= 1, Name = "Frederik", PictureUrl = "test" },
                new User() { Id=2, Name = "Admin", PictureUrl = "test2" }
            };

            // Tests
            var shopRepository = new UserRepository(ctx);

            Assert.AreEqual(shopRepository.GetAll().Count, 2);
        }
Beispiel #3
0
        public void CleanDatabase()
        {
            var ctx = new UserContext();

            // Create Fake user Data, this will replace our Database entries.
            var userList = new List<User>
            {
                new User() { Id= 1, Name = "Frederik", PictureUrl = "test" },
                new User() { Id=2, Name = "Admin", PictureUrl = "test2" }
            };

            foreach (var user in userList)
            {
                var dbUser = ctx.Users.SingleOrDefault(u => u.Name.Equals(user.Name) && u.PictureUrl.Equals(user.PictureUrl));
                ctx.Users.Remove(dbUser);
            }

            ctx.SaveChanges();
        }
Beispiel #4
0
        public void SeedDatabase()
        {
            var ctx = new UserContext();

            // Create Fake user Data, this will replace our Database entries.
            var userList = new List<User>
            {
                new User() { Id= 1, Name = "Frederik", PictureUrl = "test" },
                new User() { Id=2, Name = "Admin", PictureUrl = "test2" }
            };

            foreach (var user in userList)
            {
                ctx.Users.Add(new User() { Name = user.Name, PictureUrl = user.PictureUrl });
            }

            ctx.SaveChanges();
        }