示例#1
0
        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);
            }
        }
示例#2
0
        public ActionResult Delete(int id, HourFormModel model)
        {
            try
            {
                var hour = HourService.HourFetch(id);

                this.Map(hour, model, true);

                HourService.HourDelete(id);

                return(this.View("DeleteSuccess", model));
            }
            catch (Exception ex)
            {
                this.ModelState.AddModelError(string.Empty, ex.Message);
            }

            return(this.View(model));
        }
        public void Hour_Delete()
        {
            var hour = BusinessHelper.CreateHourAndLogon(
                HourTestsWithRoleReview.UserName,
                HourTestsWithRoleReview.UserPassword);

            Exception exception = null;

            try
            {
                HourService.HourDelete(hour.HourId);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsTrue(exception != null, "Exception should not be null");
            Assert.IsTrue(exception.GetBaseException() is SecurityException);
        }
示例#4
0
        public void Hour_Cannot_Delete_Record_For_Different_User()
        {
            var hour = BusinessHelper.CreateHourAndLogon(
                HourTestsWithRoleContribute.UserName,
                HourTestsWithRoleContribute.UserPassword);

            Exception exception = null;

            try
            {
                HourService.HourDelete(hour.HourId);
            }
            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");
        }
示例#5
0
        public void Hour_Delete()
        {
            var hour = BusinessHelper.CreateHourForUserAndLogon(
                HourTestsWithRoleContribute.UserName,
                HourTestsWithRoleContribute.UserPassword,
                HourTestsWithRoleContribute.User.UserId);

            Exception exception = null;

            try
            {
                HourService.HourDelete(hour.HourId);
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.IsTrue(exception == null, "Exception should be null");
        }
示例#6
0
        public void Hour_Cannot_Delete_Where_Is_Archived_Property_Is_True()
        {
            var hour = BusinessHelper.CreateHourThatIsArchivedAndLogon(
                HourTestsWithRoleContribute.UserName,
                HourTestsWithRoleContribute.UserPassword);

            Exception exception = null;

            try
            {
                HourService.HourDelete(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");
        }