protected void Setup() { this.ChildSetup(); this.errorResultModel = null; this.portalSettings = new PortalSettings(); this.portalSettings.PortalId = this.testPortalId; this.testPortalId = 0; }
protected void Setup() { ChildSetup(); errorResultModel = null; portalSettings = new PortalSettings(); portalSettings.PortalId = testPortalId; testPortalId = 0; }
public void RunBeforeEveryTest() { _userValidatorMock = new Mock <IUserValidator>(); _recyclebinControllerMock = new Mock <IRecyclebinController>(); _portalSettings = new PortalSettings(); _portalSettings.PortalId = _testPortalId; _errorResultModel = null; }
public void Run_GetUserWithValidCommand_ShouldErrorResponse() { // Arrange errorResultModel = new ConsoleErrorResultModel(); _userValidatorMock .Setup(u => u.ValidateUser(_userId, portalSettings, null, out _userInfo)) .Returns(errorResultModel); // Act var result = RunCommand(_userId.ToString()); // Assert Assert.IsTrue(result.IsError); }
public void Run_UserIdNull_ReturnErrorResponse() { // Arrange UserInfo userInfo; errorResultModel = new ConsoleErrorResultModel(); _userValidatorMock .Setup(u => u.ValidateUser(-1, portalSettings, null, out userInfo)) .Returns(errorResultModel); // Act var result = RunCommand("--username", "testusername", "--firstname", "testfirstname", "--lastname", "testlastname"); // Assert Assert.IsTrue(result.IsError); }
public void Run_DeleteNullUserId_ReturnErrorResponse() { // Arrange UserInfo userinfo; errorResultModel = new ConsoleErrorResultModel(); _userValidatorMock .Setup(u => u.ValidateUser(-1, portalSettings, null, out userinfo)) .Returns(errorResultModel); // Act var result = RunCommand(); // Assert Assert.IsTrue(result.IsError); }
public void RunBeforeAnyTest() { _errorResultModel = null; _userValidatorMock = new Mock <IUserValidator>(); _userControllerWrapperMock = new Mock <IUserControllerWrapper>(); _userInfo = new UserInfo(); var profile = new UserProfile(); profile.FirstName = "testUser"; _userInfo.UserID = _userId.Value; _userInfo.Profile = profile; _portalSettings = new PortalSettings(); _portalSettings.PortalId = _testPortalId; _userValidatorMock.Setup(u => u.ValidateUser(_userId, _portalSettings, null, out _userInfo)).Returns(_errorResultModel); }
public void Run_AddRolesWhenUserNotValid_ReturnErrorResponse() { // Arrange var userId = 2; UserInfo userInfo = null; errorResultModel = new ConsoleErrorResultModel("Invalid userId"); _userValidatorMock .Setup(u => u.ValidateUser(userId, portalSettings, null, out userInfo)) .Returns(errorResultModel); // Act var result = RunCommand(userId.ToString()); // Assert Assert.IsTrue(result.IsError); }
public void Run_RestoreNullUserId_ReturnErrorResponse() { // Arrange _errorResultModel = new ConsoleErrorResultModel(); UserInfo userinfo; _userValidatorMock .Setup(u => u.ValidateUser(-1, _portalSettings, null, out userinfo)) .Returns(_errorResultModel); var command = SetupCommand(string.Empty); // Act var result = command.Run(); // Assert Assert.IsTrue(result.IsError); }
public void Run_UserIdNull_ReturnErrorResponse() { // Arrange UserInfo userinfo; ConsoleErrorResultModel errorResponse = new ConsoleErrorResultModel(); _userValidatorMock .Setup(u => u.ValidateUser(-1, _portalSettings, null, out userinfo)) .Returns(errorResponse); var args = new[] { "--username", "testusername", "--firstname", "testfirstname", "--lastname", "testlastname" }; var command = SetupCommand(string.Empty, args); // Act var result = command.Run(); // Assert Assert.IsTrue(result.IsError); }
public void Run_ValidCommand_ReturnSuccessResponse(string attributeName, string attributeValue) { // Arrange var userId = 4; UserInfo userInfo = new UserInfo(); var profile = new UserProfile(); profile.FirstName = "testUser"; userInfo.UserID = userId; userInfo.Profile = profile; userInfo.FirstName = "userFirstName"; userInfo.LastName = "userLastName"; userInfo.Email = "*****@*****.**"; userInfo.IsDeleted = false; userInfo.PortalID = _testPortalId; ConsoleErrorResultModel errorResponse = null; _userValidatorMock .Setup(u => u.ValidateUser(userId, _portalSettings, null, out userInfo)) .Returns(errorResponse); _userControllerWrapperMock .Setup(w => w.GetUserById(_testPortalId, userId)) .Returns(userInfo); var args = new[] { "--firstname", "user4", "--lastname", "user4", attributeName, attributeValue }; var command = SetupCommand(userId.ToString(), args); // Act var result = command.Run(); // Assert Assert.IsFalse(result.IsError); Assert.AreEqual(1, result.Records); }
public override ConsoleResultModel Run() { var lst = new List <UserModel>(); // if no argument, default to current user if (this.Args.Length == 1) { lst.Add(new UserModel(this.User)); } else { var recCount = 0; var userId = this.UserId; if (!userId.HasValue && !string.IsNullOrEmpty(this.Username)) { // do username lookup var searchTerm = this.Username.Replace("%", "").Replace("*", "%"); userId = this._userControllerWrapper.GetUsersByUserName(this.PortalId, searchTerm, -1, int.MaxValue, ref recCount, true, false) ?? UserIdZero; // search against superusers if no regular user found if (userId == UserIdZero) { // userId = (UserController.GetUsersByUserName(-1, searchTerm, -1, int.MaxValue, ref recCount, true, true).ToArray().FirstOrDefault() as UserInfo)?.UserID ?? UserIdZero; userId = this._userControllerWrapper.GetUsersByUserName(-1, searchTerm, -1, int.MaxValue, ref recCount, true, true) ?? UserIdZero; } } else if (!userId.HasValue && !string.IsNullOrEmpty(this.Email)) { // must be email var searchTerm = this.Email.Replace("%", "").Replace("*", "%"); userId = this._userControllerWrapper.GetUsersByEmail(this.PortalId, searchTerm, -1, int.MaxValue, ref recCount, true, false) ?? UserIdZero; // search against superusers if no regular user found if (userId == UserIdZero) { userId = this._userControllerWrapper.GetUsersByEmail(-1, searchTerm, -1, int.MaxValue, ref recCount, true, true) ?? UserIdZero; } } UserInfo userInfo; ConsoleErrorResultModel errorResultModel = this._userValidator.ValidateUser(userId, this.PortalSettings, this.User, out userInfo); if (errorResultModel != null) { return(errorResultModel); } lst.Add(new UserModel(userInfo)); } return(new ConsoleResultModel(string.Empty) { Data = lst, Records = lst.Count, FieldOrder = new[] { "UserId", "Username", "DisplayName", "FirstName", "LastName", "Email", "LastActivity", "LastLogin", "LastLockout", "LastPasswordChange", "IsDeleted", "IsAuthorized", "IsLockedOut", "Created" }, }); }