Пример #1
0
        public void TaskType_Make_New_Assign_Tasks_And_Remove()
        {
            TaskType tt = new TaskType();
            tt.Alias = Guid.NewGuid().ToString("N");
            tt.Save();
            Assert.IsTrue(tt.Id > 0);

            Task t = new Task();
            t.Comment = Guid.NewGuid().ToString("N");
            t.Node = Document.GetRootDocuments().First();
            t.ParentUser = m_User;
            t.User = m_User;
            t.Type = TaskType.GetAll().First();
            t.Save();

            //delete the task type
            tt.Delete();

            //ensure they're gone
            Assert.AreEqual(0, Task.GetTasksByType(tt.Id).Count);

            //ensure the type is gone
            Assert.AreEqual(0, TaskType.GetAll().Where(x => x.Id == tt.Id).Count());

        }
Пример #2
0
        public void TaskType_Make_Duplicate()
        {
            var alias = Guid.NewGuid().ToString("N");

            var tt = new TaskType();
            tt.Alias = alias;
            tt.Save();

            //try to insert a duplicate
            var tt2 = new TaskType();
            tt2.Alias = alias;
            var hasException = false;
            try
            {
                tt2.Save();
            }
            catch (SqlHelperException)
            {
                hasException = true;
            }
            Assert.IsTrue(hasException);

            //try to update to a duplicate
            var tt3 = new TaskType();
            tt3.Alias = Guid.NewGuid().ToString("N");
            tt3.Save();
            tt3.Alias = alias;
            hasException = false;
            try
            {
                tt3.Save();
            }
            catch (SqlHelperException)
            {
                hasException = true;
            }
            Assert.IsTrue(hasException);

            //now remove the ones we've created
            tt.Delete();
            tt3.Delete();
        }