Example #1
0
        public void MiddleTier_GetListTasksSpecialChars()
        {
            //Tests special chars, new lines, Date, DateTime, and enum values in a list of objects as the parameter and the return value
            List <OpenDentBusiness.Task> listTasks = new List <OpenDentBusiness.Task> {
                new OpenDentBusiness.Task {
                    Descript      = WebServiceTests.DirtyString,
                    ParentDesc    = WebServiceTests.NewLineString,
                    DateTask      = WebServiceTests.DateTodayTest,
                    DateTimeEntry = WebServiceTests.DateTEntryTest,
                    TaskStatus    = TaskStatusEnum.Done
                }
            };
            List <OpenDentBusiness.Task> listTasksReturned = WebServiceTests.GetListTasksSpecialChars(listTasks);
            List <string> strErrors = new List <string>();

            if (listTasksReturned == null || listTasksReturned.Count < 1)
            {
                strErrors.Add(listTasksReturned == null?"The list of tasks is null.":"The list of tasks contains an insufficient number of tasks.");
            }
            int idx = 0;

            foreach (OpenDentBusiness.Task task in listTasksReturned)
            {
                if (task == null)
                {
                    strErrors.Add("The tasklist contains a null task.");
                    idx++;
                    continue;
                }
                if (idx == 0 && task.Descript != WebServiceTests.DirtyString)
                {
                    strErrors.Add(string.Format(@"The task.Descript should be {0} but returned {1}.", WebServiceTests.DirtyString, task.Descript ?? "null"));
                }
                if (task.ParentDesc != WebServiceTests.NewLineString)
                {
                    strErrors.Add(string.Format(@"The task.ParentDesc should be {0} but returned {1}.", WebServiceTests.NewLineString, task.ParentDesc ?? "null"));
                }
                if (task.DateTask == null || task.DateTask.Date != WebServiceTests.DateTodayTest.Date)
                {
                    strErrors.Add(string.Format("The task.DateTask should be {0} but returned {1}.", WebServiceTests.DateTodayTest.ToShortDateString(),
                                                task.DateTask == null?"null":task.DateTask.ToShortDateString()));
                }
                if (task.DateTimeEntry != WebServiceTests.DateTEntryTest)
                {
                    strErrors.Add(string.Format("The task.DateTimeEntry should be {0} but returned {1}.", WebServiceTests.DateTEntryTest.ToString(),
                                                task.DateTimeEntry == null?"null":task.DateTimeEntry.ToString()));
                }
                if (task.TaskStatus != TaskStatusEnum.Done)
                {
                    strErrors.Add(string.Format("The task.TaskStatus should be {0} but returned {1}.", TaskStatusEnum.Done, task.TaskStatus));
                }
                idx++;
            }
            Assert.IsTrue(strErrors.Count == 0);
        }