示例#1
0
        public void ImmediateDeleteProject()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj             = obj.Save();

            ProjectEdit.DeleteProject(obj.Id);

            Assert.IsFalse(ProjectEdit.Exists(obj.Id));
        }
示例#2
0
 public ActionResult Delete(int id, FormCollection collection)
 {
     try
     {
         ProjectEdit.DeleteProject(id);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         ViewData.Model = ProjectEdit.GetProject(id);
         ModelState.AddModelError("", ex.Message);
         return(View());
     }
 }
        public void CloseProject()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj.Started     = DateTime.Today.Subtract(new TimeSpan(5, 0, 0));
            obj             = obj.Save();

            var result = ProjectCloser.CloseProject(obj.Id);

            Assert.IsTrue(result.Closed);

            ProjectEdit.DeleteProject(obj.Id);
        }
示例#4
0
        public void InsertProject()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj             = obj.Save();
            Assert.IsTrue(obj.Id > 0);
            Assert.IsFalse(obj.IsNew);
            Assert.IsFalse(obj.IsDirty);
            Assert.IsFalse(obj.IsSavable);
            Assert.IsTrue(ProjectEdit.Exists(obj.Id));

            ProjectEdit.DeleteProject(obj.Id);
        }
示例#5
0
        public void AddProjectResource()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj.Resources.Assign(1);
            obj = obj.Save();

            obj = ProjectEdit.GetProject(obj.Id);
            Assert.IsTrue(obj.Resources.Count > 0);
            Assert.AreEqual(1, obj.Resources[0].ResourceId);

            ProjectEdit.DeleteProject(obj.Id);
        }
示例#6
0
        public void AddResourceAssignment()
        {
            var obj = ResourceEdit.NewResourceEdit();

            obj.FirstName = "Rocky";
            obj.LastName  = "Lhotka";
            obj.Assignments.AssignTo(1);
            obj = obj.Save();

            obj = ResourceEdit.GetResourceEdit(obj.Id);
            Assert.IsTrue(obj.Assignments.Count > 0);
            Assert.AreEqual(1, obj.Assignments[0].ProjectId);

            ProjectEdit.DeleteProject(obj.Id);
        }
示例#7
0
        public void RemoveProjectResource()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj.Resources.Assign(1);
            obj = obj.Save();

            obj.Resources.Remove(1);
            obj = obj.Save();

            obj = ProjectEdit.GetProject(obj.Id);
            Assert.AreEqual(0, obj.Resources.Count);

            ProjectEdit.DeleteProject(obj.Id);
        }
示例#8
0
        public void UpdateProject()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj             = obj.Save();

            obj             = ProjectEdit.GetProject(obj.Id);
            obj.Name        = "Test 2";
            obj.Description = "More testing";
            obj.Started     = DateTime.Today;
            obj.Ended       = DateTime.Today;
            obj             = obj.Save();
            Assert.IsFalse(obj.IsNew);
            Assert.IsFalse(obj.IsDirty);
            Assert.IsFalse(obj.IsSavable);

            ProjectEdit.DeleteProject(obj.Id);
        }
        public void CloseProjectFail()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj.Started     = DateTime.Today.Subtract(new TimeSpan(5, 0, 0));
            obj.Ended       = DateTime.Today;
            obj             = obj.Save();

            try
            {
                var result = ProjectCloser.CloseProject(obj.Id);
            }
            catch (Csla.DataPortalException ex)
            {
                throw ex.BusinessException;
            }
            finally
            {
                ProjectEdit.DeleteProject(obj.Id);
            }
        }
示例#10
0
        public void CloseProjectAsync()
        {
            var obj = ProjectEdit.NewProject();

            obj.Name        = "Test";
            obj.Description = "This is a test";
            obj.Started     = DateTime.Today.Subtract(new TimeSpan(5, 0, 0));
            obj             = obj.Save();

            var sync = new AutoResetEvent(false);

            ProjectCloser.CloseProject(obj.Id, (o, e) =>
            {
                if (e.Error != null)
                {
                    Assert.Fail(e.Error.Message);
                }
                var result = e.Object;
                Assert.IsTrue(result.Closed);
            });
            sync.WaitOne(1000);

            ProjectEdit.DeleteProject(obj.Id);
        }