public void ManagerUserUpdateSuccessThree() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( "用户5", "123456", "系统管理员"); ManagerUser createdManagerUser = managerUserStorage.CreateManagerUser(myManagerUser); Assert.AreNotEqual( 0, createdManagerUser.UserID, string.Format("Could not create ManagerUser:{0}", createdManagerUser.UserID)); myManagerUser.UserSort = "系统操作员"; managerUserStorage.UpdateManagerUser(myManagerUser); ManagerUser updatedManagerUser = managerUserStorage.ReadManagerUser( createdManagerUser.UserID); AssertManagerUserItemEqual(myManagerUser, updatedManagerUser); }
public void ManagerUserCreateFailureUserNameArgumentNullException() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( null, "123456", "系统管理员"); managerUserStorage.CreateManagerUser(myManagerUser); }
public void ManagerUserCreateFailureUserPasswordArgumentNullException() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( "用户3", null, "系统管理员"); managerUserStorage.CreateManagerUser(myManagerUser); }
public void ManagerUserUpdateFailureUserIdArgumentException() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( "用户6", "123456", "系统管理员"); managerUserStorage.CreateManagerUser(myManagerUser); myManagerUser.UserID = int.MaxValue; managerUserStorage.UpdateManagerUser(myManagerUser); }
public void ManagerUserUpdateFailureUserPasswordArgumentNullException() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( "用户6", "123456", "系统管理员"); managerUserStorage.CreateManagerUser(myManagerUser); myManagerUser.UserPassword = null; managerUserStorage.UpdateManagerUser(myManagerUser); }
public void ManagerUserCreateSuccess() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( "用户1", "123456", "系统管理员"); ManagerUser createdManagerUser = managerUserStorage.CreateManagerUser(myManagerUser); Assert.AreNotEqual( 0, createdManagerUser.UserID, string.Format("Could not create ManagerUser:{0}", createdManagerUser.UserID)); AssertManagerUserItemEqual(myManagerUser, createdManagerUser); }
private void btnAdd_Click(object sender, EventArgs e) { ManagerUser managerUser = new ManagerUser(); IManagerUserStorage managerUserStorage = new ManagerUserStorage(); if (textUserName.Text.Trim() == "" || textUserPassword.Text.Trim() == "" || cmbUserSort.Text == "") { MessageBox.Show("请输入全部信息,不要有遗漏。"); } else { managerUser.UserName = textUserName.Text.Trim(); managerUser.UserPassword = textUserPassword.Text.Trim(); managerUser.UserSort = cmbUserSort.Text.Trim(); switch (cmbUserSort.SelectedIndex) { case 1: managerUser.UserSort = "系统管理员"; break; case 2: managerUser.UserSort = "系统操作员"; break; default: managerUser.UserSort = null; break; } managerUserStorage.CreateManagerUser(managerUser); MessageBox.Show("增加成功!"); textUserName.Text = ""; textUserPassword.Text = ""; cmbUserSort.Text = ""; } }
//这个属性其实非常有用处,它表明这个函数会抛出一个预期的异常。 public void ManagerUserCreateFailureManagerUserArgumentNullException() { IManagerUserStorage managerUserStorage = new ManagerUserStorage(); managerUserStorage.CreateManagerUser(null); }
public void ManagerUserListSuccess() { List <ManagerUser> managerUserList = new List <ManagerUser>(); IManagerUserStorage managerUserStorage = new ManagerUserStorage(); ManagerUser myManagerUser = CreateManagerUserForTest( "用户7", "123456", "系统管理员"); ManagerUser createdManagerUser = managerUserStorage.CreateManagerUser(myManagerUser); managerUserList.Add(createdManagerUser); myManagerUser = CreateManagerUserForTest( "用户8", "123456", "系统操作员"); createdManagerUser = managerUserStorage.CreateManagerUser(myManagerUser); managerUserList.Add(createdManagerUser); myManagerUser = CreateManagerUserForTest( "用户9", "123456", "系统操作员"); createdManagerUser = managerUserStorage.CreateManagerUser(myManagerUser); managerUserList.Add(createdManagerUser); QueryManagerUser queryManagerUser = new QueryManagerUser(); queryManagerUser.UserID = null; queryManagerUser.UserName = null; queryManagerUser.UserPassword = null; queryManagerUser.UserSort = null; IList <ManagerUser> readedManagerUserList = managerUserStorage.ListManagerUser(queryManagerUser); AssertManagerUserListsEqual(managerUserList, readedManagerUserList); managerUserList.RemoveAt(0); queryManagerUser = new QueryManagerUser(); queryManagerUser.UserID = null; queryManagerUser.UserName = null; queryManagerUser.UserPassword = null; queryManagerUser.UserSort = "系统操作员"; readedManagerUserList = managerUserStorage.ListManagerUser(queryManagerUser); AssertManagerUserListsEqual(managerUserList, readedManagerUserList); managerUserList.RemoveAt(0); queryManagerUser = new QueryManagerUser(); queryManagerUser.UserID = null; queryManagerUser.UserName = "******"; queryManagerUser.UserPassword = null; queryManagerUser.UserSort = null; readedManagerUserList = managerUserStorage.ListManagerUser(queryManagerUser); AssertManagerUserListsEqual(managerUserList, readedManagerUserList); }