Пример #1
0
        public void GetAllOnUserRepository()
        {
            //Arrange
            UserRepository userRepository = new UserRepository(_config);

            //Act
            List<User> users = userRepository.GetAll().ToList();

            //Assert
            CollectionAssert.AreEqual(_users, users);
        }
Пример #2
0
        public void GetOnUserRepository()
        {
            //Arrange
            UserRepository userRepository = new UserRepository(_config);

            //Act
            User user = userRepository.Get(new Guid("7b8ceac1-9fb1-4e15-af4b-890b1f0c3ebf"));

            //Assert
            Assert.AreEqual(_users[0], user);

            userRepository.Dispose();
        }
Пример #3
0
        public void DeleteOnUserRepository()
        {
            //Arrange
            UserRepository userRepository = new UserRepository(_config);

            var userToDelete = _users[1];

            //Act
            userRepository.Delete(userToDelete.Id);

            User user = userRepository.Get(userToDelete.Id);

            //Assert
            Assert.IsNull(user);
        }
Пример #4
0
        public void CreateOnUserRepository()
        {
            //Arrange
            UserRepository userRepository = new UserRepository(_config);

            var userToCreate = new User
            {
                Username = "******",
                Password = "******"
            };

            //Act
            Guid id = userRepository.Create(userToCreate);

            User user = userRepository.Get(id);

            //Assert
            Assert.AreEqual(user, userToCreate);
            Assert.IsNotNull(id);
        }
Пример #5
0
        static void Main(string[] args)
        {
            //PhonebookEntities phonebookEntities = new PhonebookEntities(Properties.Settings.Default.FilePaths, Properties.Settings.Default.UserFile);
            //Console.WriteLine();

            //UserRepository userRepository = new UserRepository();

            //userRepository.Create(new User {Password = "******", Username = "******"});
            //userRepository.Create(new User { Password = "******", Username = "******" });

            //userRepository.Dispose();

            UserRepository userRepository = new UserRepository();

            List<User> users = userRepository.GetAll().ToList();

            User userToUpdate = userRepository.Get(users[0].Id);

            userToUpdate.Username = "******";

            userRepository.Update(userToUpdate);

            userRepository.Create(new User { Password = "******", Username = "******" });

            List<User> users2 = userRepository.GetAll().ToList();

            foreach (var user in users2)
            {
                Console.WriteLine("Username: "******", Password: " + user.Password);
            }

            userRepository.Delete(users2[2].Id);

            userRepository.Dispose();

            Console.ReadLine();
        }
Пример #6
0
        public void UpdateOnUserRepository()
        {
            //Arrange
            UserRepository userRepository = new UserRepository(_config);

            var userToUpdate = _users[1];
            userToUpdate.Password = "******";

            //Act
            userRepository.Update(userToUpdate);

            User user = userRepository.Get(userToUpdate.Id);

            //Assert
            Assert.AreEqual(user, userToUpdate);
        }