コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
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);
        }