public static Hour CreateHourThatIsArchivedAndLogon(string userName, string userPassword) { var name = DataHelper.RandomString(20); var password = DataHelper.RandomString(20); BusinessHelper.CreateUserWithFullControl(name, password); BusinessPrincipal.Login(name, password); var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); hour.IsArchived = true; hour = HourService.HourSave(hour); BusinessPrincipal.Logout(); BusinessPrincipal.Login(userName, userPassword); return(hour); }
public ActionResult Create(TaskFormModel model) { var task = TaskService.TaskNew(); this.MapToObject(model, task); task = TaskService.TaskSave(task); if (task.IsValid) { if (model.HourId != 0) { var hour = HourService.HourFetch(model.HourId); hour.TaskId = task.TaskId; HourService.HourSave(hour); } return(new JsonResult { Data = this.Url.Action("Edit", new { id = task.TaskId, message = Resources.SaveSuccessfulMessage }) }); } this.MapToModel(task, model, false); return(this.View(model)); }
public void Hour_Fetch_List() { var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); HourService.HourSave(hour); hour = HourService.HourNew(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); HourService.HourSave(hour); var hours = HourService.HourFetchInfoList(); Assert.IsTrue(hours.Count > 1, "Hours should be greater than one"); }
public void Hour_Delete() { var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); hour = HourService.HourSave(hour); hour = HourService.HourFetch(hour.HourId); HourService.HourDelete(hour.HourId); try { HourService.HourFetch(hour.HourId); } catch (Exception ex) { Assert.IsTrue(ex.GetBaseException() is InvalidOperationException); } }
public void Hour_Edit() { var hour = HourService.HourNew(); var notes = DataHelper.RandomString(100); var task = BusinessHelper.CreateTask(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = notes; Assert.IsTrue(hour.IsValid, "IsValid should be true"); hour = HourService.HourSave(hour); hour = HourService.HourFetch(hour.HourId); hour.Notes = DataHelper.RandomString(100); hour = HourService.HourSave(hour); hour = HourService.HourFetch(hour.HourId); Assert.IsTrue(hour.Notes != notes, "Notes should have different value"); }
public static Hour CreateHour() { var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); hour = HourService.HourSave(hour); return(hour); }
public void Hour_Add() { var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); Assert.IsTrue(hour.IsValid, "IsValid should be true"); hour = HourService.HourSave(hour); }
public void Hour_Fetch() { var hour = HourService.HourNew(); var task = BusinessHelper.CreateTask(); hour.ProjectId = task.ProjectId; hour.TaskId = task.TaskId; hour.Date = DateTime.Now.Date; hour.Duration = 8; hour.Notes = DataHelper.RandomString(100); hour = HourService.HourSave(hour); hour = HourService.HourFetch(hour.HourId); Assert.IsFalse(hour == null, "Hour should not be null"); }
public ActionResult Create(int?projectId, int?taskId, HourFormModel model) { var hour = HourService.HourNew(); Csla.Data.DataMapper.Map(model, hour, true); hour = HourService.HourSave(hour); if (hour.IsValid) { return(new JsonResult { Data = this.Url.Action("Edit", new { id = hour.HourId, message = Resources.SaveSuccessfulMessage }) }); } this.Map(hour, model, false); return(this.View(model)); }
public ActionResult Edit(int id, HourFormModel model) { var hour = HourService.HourFetch(id); Csla.Data.DataMapper.Map(model, hour, true); hour = HourService.HourSave(hour); if (hour.TaskId != 0) { model.Task = TaskService.TaskFetch(hour.TaskId); } if (hour.IsValid) { model.Message = Resources.SaveSuccessfulMessage; } this.Map(hour, model, true); return(this.View(model)); }
public void Hour_Edit() { var hour = BusinessHelper.CreateHourAndLogon( HourTestsWithRoleReview.UserName, HourTestsWithRoleReview.UserPassword); Exception exception = null; try { hour = HourService.HourFetch(hour.HourId); hour.Notes = DataHelper.RandomString(20); hour = HourService.HourSave(hour); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception != null, "Exception should not be null"); Assert.IsTrue(exception.GetBaseException() is SecurityException); }
public void Hour_Edit() { var hour = BusinessHelper.CreateHourForUserAndLogon( HourTestsWithRoleContribute.UserName, HourTestsWithRoleContribute.UserPassword, HourTestsWithRoleContribute.User.UserId); Exception exception = null; try { hour = HourService.HourFetch(hour.HourId); hour.Notes = DataHelper.RandomString(20); HourService.HourSave(hour); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception == null, "Exception should be null"); }
public void Hour_Cannot_Write_To_User_Id_Property() { var hour = BusinessHelper.CreateHourAndLogon( HourTestsWithRoleContribute.UserName, HourTestsWithRoleContribute.UserPassword); Exception exception = null; try { hour = HourService.HourFetch(hour.HourId); hour.UserId = DataHelper.RandomNumber(1000); HourService.HourSave(hour); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception != null, "Exception should not be null"); Assert.IsTrue(exception.GetBaseException() is SecurityException, "Exception should be of type SecurityException"); }
public void Hour_Cannot_Edit_Where_Is_Archived_Property_Is_True() { var hour = BusinessHelper.CreateHourThatIsArchivedAndLogon( HourTestsWithRoleContribute.UserName, HourTestsWithRoleContribute.UserPassword); Exception exception = null; try { hour = HourService.HourFetch(hour.HourId); hour.Notes = DataHelper.RandomString(100); HourService.HourSave(hour); } catch (Exception ex) { exception = ex; } Assert.IsTrue(exception != null, "Exception should not be null"); Assert.IsTrue(exception.GetBaseException() is SecurityException, "Exception should be of type SecurityException"); }