示例#1
0
 public Package(int type, UserDirectory userDirectory, User user, DungeonFileInfo fileInfo)
 {
     Type          = type;
     UserDirectory = userDirectory;
     Sub           = user.sub;
     FileTransfer  = fileInfo;
 }
示例#2
0
        public void Get_ChangingUser_trackingOption(bool tracking)
        {
            //Arrange
            string originalName = "Spider";

            UserDirectory.TryAddUser(new User()
            {
                UserName = originalName, Login = "******"
            });

            //Act
            string newName = "Gorilla";

            UserDirectory.GetUsers(tracking).Single().UserName = newName;

            var user = UserDirectory.GetUsers(tracking).Single();

            //Assert
            if (tracking)
            {
                Assert.IsTrue(user.UserName == newName);
            }
            else
            {
                Assert.IsTrue(user.UserName == originalName);
            }
        }
示例#3
0
        public void Equal_ProfileId_And_UserId(int userNumber)
        {
            //Act
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = new UserProfile()
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = new UserProfile()
            });

            //Assert
            var user = UserDirectory.GetUsers()[userNumber];

            if (user.Profile == null)
            {
                Assert.IsFalse(UserDirectory.GetUsers()
                               .Any(u => u.Profile != null && u.Profile.Id == user.Id));
            }
            else
            {
                Assert.IsTrue(user.Profile.Id == user.Id);
            }
        }
示例#4
0
        public void PutUserProfile_trackingOption(bool useTracking)
        {
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            string profileName        = "Ilya";
            string profilePhoneNumber = "100-400-600";
            string profileAddress     = "Cenral str.98";

            var firstUser = UserDirectory.GetUsers(useTracking).Single();

            firstUser.Profile = new UserProfile()
            {
                Name        = profileName,
                PhoneNumber = profilePhoneNumber,
                Address     = profileAddress
            };
            bool result = UserDirectory.TryPutUser(firstUser);

            firstUser = UserDirectory.GetUsers(useTracking).Single();
            Assert.IsTrue(result &&
                          firstUser.Profile.Name == profileName &&
                          firstUser.Profile.Address == profileAddress &&
                          firstUser.Profile.PhoneNumber == profilePhoneNumber);
        }
示例#5
0
        public void RemoveUser(int userNumber)
        {
            //Arrange
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = new UserProfile()
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = new UserProfile()
            });

            //Act
            var  user   = UserDirectory.GetUsers()[userNumber];
            bool result = UserDirectory.TryRemoveUser(user.Id, false);

            //Assert
            Assert.IsTrue(result == true);
            Assert.IsTrue(UserDirectory.GetUsers().Count() == 3);
            Assert.IsFalse(UserDirectory.GetUsers().Any(u => u.Id == user.Id || u.Login == user.Login));
        }
示例#6
0
文件: TextFile.cs 项目: drsslv/Molder
        public bool DownloadFile(string url, string filename, string pathToSave = null)
        {
            if (string.IsNullOrWhiteSpace(pathToSave))
            {
                pathToSave = UserDirectory.Get();
            }

            if (string.IsNullOrWhiteSpace(filename))
            {
                Log.Logger().LogWarning("DOWNLOAD: FileName is missing");
                throw new ArgumentException("DOWNLOAD: FileName is missing");
            }
            else
            {
                bool isValidExtension = FileProvider.CheckFileExtension(filename);
                if (isValidExtension)
                {
                    if (WebProvider.Download(url, pathToSave, filename))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    Log.Logger().LogWarning($"Check that the file \"{filename}\" has a .txt extension");
                    throw new ValidFileNameException($"Check that the file \"{filename}\" has a .txt extension");
                }
            }
        }
示例#7
0
 private void SettingsForm_Load(object sender, EventArgs e)
 {
     userDirectory = new UserDirectory();
     if (!(string.IsNullOrEmpty(userDirectory.GetPath())))
     {
         txtBoxDirPath.Text = userDirectory.GetPath();
     }
     RefreshDataGridView();
 }
示例#8
0
        public void Deny_InvalidOrEmptyLogin(string login)
        {
            bool result = UserDirectory.TryAddUser(new User()
            {
                Login = login
            });

            Assert.IsTrue(result == false && UserDirectory.GetUsers().Count == 0);
        }
示例#9
0
        public void Deny_PutNewUser()
        {
            bool result = UserDirectory.TryPutUser(new User()
            {
                Login = "******"
            });

            var userCount = UserDirectory.GetUsers().Count;

            Assert.IsTrue(result == false && userCount == 0);
        }
示例#10
0
        public bool IsExist(string filename, string path = null !)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                path = UserDirectory.Get();
            }

            var fullpath = PathProvider.Combine(path, filename);

            return(FileProvider.Exist(fullpath));
        }
示例#11
0
 private void btnSaveSettings_Click(object sender, EventArgs e)
 {
     if (!(string.IsNullOrEmpty(txtBoxDirPath.Text)))
     {
         userDirectory             = new UserDirectory(txtBoxDirPath.Text);
         userDirectory.currentPath = txtBoxDirPath.Text;
         userDirectory.SetPath();
         userDirectory.SetCurrentPath();
         MessageBox.Show(userDirectory.CreateDirectory());
     }
 }
示例#12
0
        public void GetUserName()
        {
            string userName = "******";

            UserDirectory.TryAddUser(new User()
            {
                Login = "******", UserName = userName
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].UserName == userName);
        }
示例#13
0
        public void GetRole()
        {
            string role = "testRole";

            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Role = role
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].Role == role);
        }
示例#14
0
        public void GetUserLogin()
        {
            string login = "******";

            UserDirectory.TryAddUser(new User()
            {
                Login = login
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].Login == login);
        }
示例#15
0
 public void Dispose()
 {
     Process.Kill();
     try
     {
         UserDirectory.Delete(true);
     }
     catch
     {
         Thread.Sleep(500);          // i'm being lazy because i'm tired
         UserDirectory.Delete(true);
     }
 }
示例#16
0
        public void Deny_AddDublicateUser()
        {
            var user = new User()
            {
                Login = "******"
            };

            UserDirectory.TryAddUser(user);
            UserDirectory.TryAddUser(user);

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users.Count == 1);
        }
示例#17
0
        public void GetUser_ByPassword()
        {
            string log  = "user1";
            string pass = "******";

            UserDirectory.TryAddUser(new User()
            {
                Login = log, Password = pass
            });

            var user = UserDirectory.GetUser(log, pass);

            Assert.IsTrue(user.Login == log);
        }
示例#18
0
        public void GetUser_ById()
        {
            string log = "user1";

            UserDirectory.TryAddUser(new User()
            {
                Login = log
            });

            int userId = UserDirectory.GetUsers()[0].Id;
            var user   = UserDirectory.GetUser(userId);

            Assert.IsTrue(user.Login == log);
        }
示例#19
0
        public static void InitializePaths(VariableController variableController, FeatureContext featureContext)
        {
            // User
            var userDir = new UserDirectory().Get();
            var dir     = $"{userDir}{Path.DirectorySeparatorChar}{featureContext.FeatureInfo.Title}";

            Directory.CreateDirectory(dir);
            variableController.SetPath(Infrastructures.Constants.USER_DIR, dir);

            // Bin

            var binDir = new BinDirectory().Get();

            variableController.SetPath(Infrastructures.Constants.BIN_DIR, binDir);
        }
示例#20
0
        public void Unique_UserId()
        {
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].Id != users[1].Id);
        }
示例#21
0
        public void AddUser(int countOfUser)
        {
            bool result = true;

            for (int i = 1; i <= countOfUser; i++)
            {
                result = UserDirectory.TryAddUser(new User()
                {
                    Login = $"user{i}"
                });
            }

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(result == true && users.Count == countOfUser);
        }
示例#22
0
        public void Deny_AddUser_with_DublicatedProfile()
        {
            var profile = new UserProfile();

            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = profile
            });
            bool result = UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = profile
            });

            Assert.IsFalse(result);
            Assert.IsFalse(UserDirectory.GetUsers().Count() == 2);
        }
示例#23
0
        public void PutUserName_trackingOption(bool useTracking)
        {
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            string userName = "******";

            var firstUser = UserDirectory.GetUsers(useTracking).Single();

            firstUser.UserName = userName;
            bool result = UserDirectory.TryPutUser(firstUser);

            firstUser = UserDirectory.GetUsers(useTracking).Single();
            Assert.IsTrue(result && firstUser.UserName == userName);
        }
示例#24
0
        public void GetProfileName()
        {
            string profileName = "Vasil";
            var    profile     = new UserProfile()
            {
                Name = profileName
            };

            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = profile
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].Profile.Name == profileName);
        }
示例#25
0
        public void GetProfileAddress()
        {
            string address = "Central park street. 25";
            var    profile = new UserProfile()
            {
                Address = address
            };

            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = profile
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].Profile.Address == address);
        }
示例#26
0
        public void GetProfilePhoneNumber()
        {
            string phoneNumber = "123-25-678";
            var    profile     = new UserProfile()
            {
                PhoneNumber = phoneNumber
            };

            UserDirectory.TryAddUser(new User()
            {
                Login = "******", Profile = profile
            });

            var users = UserDirectory.GetUsers();

            Assert.IsTrue(users[0].Profile.PhoneNumber == phoneNumber);
        }
示例#27
0
        public void Get_tracked_ChangingUser()
        {
            bool   trackingOption = true;
            string originalName   = "Spider";
            string newName        = "Gorilla";

            UserDirectory.TryAddUser(new User()
            {
                UserName = originalName, Login = "******"
            });

            UserDirectory.GetUsers(trackingOption).Single()
            .UserName = newName;
            var user = UserDirectory.GetUsers(trackingOption).Single();

            Assert.IsTrue(user.UserName == newName);
        }
示例#28
0
        public void Deny_RemoveUser_by_incorrect_Id()
        {
            //Arrange
            UserDirectory.TryAddUser(new User()
            {
                Login = "******"
            });
            var user = UserDirectory.GetUsers().Single();

            //Act
            bool result = UserDirectory.TryRemoveUser(user.Id + 100, false);

            //Assert
            Assert.IsFalse(result);
            Assert.IsFalse(UserDirectory.GetUsers().Count() == 0);
            Assert.IsTrue(UserDirectory.GetUsers().Any(u => u.Id == user.Id && u.Login == user.Login));
        }
示例#29
0
 public HomeController()
 {
     if (MessageRepo.Messages.Count == 0)
     {
         message = new Message()
         {
             MessageSender   = "John",
             MessageReceiver = "Jane",
             MessageText     = "Hello"
         };
         MessageRepo.AddMessage(message);
     }
     if (UserDirectory.Users.Count == 0)
     {
         UserDirectory.AddUser(John);
         UserDirectory.AddUser(Jane);
     }
 }
示例#30
0
        public void Deny_ChangeLogin()
        {
            bool   useTracking = false;
            string oldLogin    = "******";

            UserDirectory.TryAddUser(new User()
            {
                Login = oldLogin
            });

            var firstUser = UserDirectory.GetUsers(useTracking)[0];

            firstUser.Login = "******";
            bool result = UserDirectory.TryPutUser(firstUser);

            firstUser = UserDirectory.GetUsers()[0];
            Assert.IsTrue(result == false && firstUser.Login == oldLogin);
        }