private Employee AddRandomEmployee() { Employee employee = new Employee() { Alias = this._random.Next().ToString(), Manager = this._random.Next().ToString(), Name = this._random.Next().ToString(), }; ExpenseService service = new ExpenseService(); service.SaveEmployee(employee); return employee; }
public void Create_Employee() { string alias = "rogreen"; Employee employee = new Employee() { Alias = alias, Manager = "notrogreen", Name = "Robert Green", }; ExpenseService service = new ExpenseService(); int employeeId = service.SaveEmployee(employee); Assert.AreNotEqual(0, employeeId); Assert.AreEqual(employeeId, employee.EmployeeId); Employee dbData = service.GetEmployee(alias); Assert.AreEqual(alias, dbData.Alias); alias = "rogreen2"; employee.Alias = alias; service.SaveEmployee(employee); dbData = service.GetEmployee(alias); Assert.AreEqual(alias, dbData.Alias); }
public void Create_Employee_WithDuplicateAlias() { Employee employee = this.AddRandomEmployee(); employee.EmployeeId = 0; ExpenseService service = new ExpenseService(); service.SaveEmployee(employee); }