示例#1
0
        public void GetUsersReturnsUsers()
        {
            using (var sqliteWrapper = new SqliteWrapper())
            {
                using (var context = sqliteWrapper.GetContext())
                {
                    context.Users.Add(new User {
                        Username = "******"
                    });
                    context.Users.Add(new User {
                        Username = "******"
                    });
                    context.Users.Add(new User {
                        Username = "******"
                    });
                    context.SaveChanges();
                }

                IEnumerable <User> users;

                using (var context = sqliteWrapper.GetContext())
                {
                    var userService = new UserRepository(context);
                    users = userService.GetUsers();
                }

                Assert.AreEqual(3, users.Count());
            }
        }
示例#2
0
        public void GetUserGuidReturnsUser()
        {
            var guid = System.Guid.NewGuid();

            using (var sqliteWrapper = new SqliteWrapper())
            {
                using (var context = sqliteWrapper.GetContext())
                {
                    context.Users.Add(new User {
                        Guid = guid, Username = "******"
                    });
                    context.SaveChanges();
                }

                User user;

                using (var context = sqliteWrapper.GetContext())
                {
                    var userService = new UserRepository(context);
                    user = userService.GetUser(guid);
                }

                Assert.AreEqual(guid, user.Guid);
            }
        }
示例#3
0
        public void GetUserUsernamePasswordReturnsUser()
        {
            using (var sqliteWrapper = new SqliteWrapper())
            {
                using (var context = sqliteWrapper.GetContext())
                {
                    context.Users.Add(new User {
                        Username = "******", Password = "******"
                    });
                    context.SaveChanges();
                }

                User user;

                using (var context = sqliteWrapper.GetContext())
                {
                    var userService = new UserRepository(context);
                    user = userService.GetUser("test", "password");
                }

                Assert.AreEqual("test", user.Username);
            }
        }