public Package(int type, UserDirectory userDirectory, User user, DungeonFileInfo fileInfo) { Type = type; UserDirectory = userDirectory; Sub = user.sub; FileTransfer = fileInfo; }
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); } }
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); } }
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); }
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)); }
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"); } } }
private void SettingsForm_Load(object sender, EventArgs e) { userDirectory = new UserDirectory(); if (!(string.IsNullOrEmpty(userDirectory.GetPath()))) { txtBoxDirPath.Text = userDirectory.GetPath(); } RefreshDataGridView(); }
public void Deny_InvalidOrEmptyLogin(string login) { bool result = UserDirectory.TryAddUser(new User() { Login = login }); Assert.IsTrue(result == false && UserDirectory.GetUsers().Count == 0); }
public void Deny_PutNewUser() { bool result = UserDirectory.TryPutUser(new User() { Login = "******" }); var userCount = UserDirectory.GetUsers().Count; Assert.IsTrue(result == false && userCount == 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)); }
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()); } }
public void GetUserName() { string userName = "******"; UserDirectory.TryAddUser(new User() { Login = "******", UserName = userName }); var users = UserDirectory.GetUsers(); Assert.IsTrue(users[0].UserName == userName); }
public void GetRole() { string role = "testRole"; UserDirectory.TryAddUser(new User() { Login = "******", Role = role }); var users = UserDirectory.GetUsers(); Assert.IsTrue(users[0].Role == role); }
public void GetUserLogin() { string login = "******"; UserDirectory.TryAddUser(new User() { Login = login }); var users = UserDirectory.GetUsers(); Assert.IsTrue(users[0].Login == login); }
public void Dispose() { Process.Kill(); try { UserDirectory.Delete(true); } catch { Thread.Sleep(500); // i'm being lazy because i'm tired UserDirectory.Delete(true); } }
public void Deny_AddDublicateUser() { var user = new User() { Login = "******" }; UserDirectory.TryAddUser(user); UserDirectory.TryAddUser(user); var users = UserDirectory.GetUsers(); Assert.IsTrue(users.Count == 1); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); } }
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); }