Example #1
0
        static List <Job> GetOrderedJobListFromString(string jobs)
        {
            // create the sorter
            var jobsSorter = JobsSorterBuilder.CreateJobsSorter();

            return(jobsSorter.GetOrderedJobList(jobs.ToUpper()));
        }
        public void GetOrderedJobListTest_EmptyString()
        {
            // arrange
            var jobString  = "";
            var expected   = new List <Job>();
            var jobsSorter = JobsSorterBuilder.CreateJobsSorter();

            // act
            var actual = jobsSorter.GetOrderedJobList(jobString.ToUpper());

            // assert
            CollectionAssert.AreEqual(expected, actual);
        }
        public void GetOrderedJobListTest_SingleJob()
        {
            // arrange
            var jobString = "a";
            var expected  = new List <Job>
            {
                jobA
            };
            var jobsSorter = JobsSorterBuilder.CreateJobsSorter();

            // act
            var actual = jobsSorter.GetOrderedJobList(jobString.ToUpper());

            // assert
            CollectionAssert.AreEqual(expected, actual, new JobsComparerByName());
        }
        public void GetOrderedJobListTest_CircularDependencyError()
        {
            // arrange
            var jobString  = "a=>b;b=>c;c=>a";
            var expected   = "Error: There is atleast one cyclic dependency";
            var jobsSorter = JobsSorterBuilder.CreateJobsSorter();

            // act
            try
            {
                var actual = jobsSorter.GetOrderedJobList(jobString.ToUpper());
            }
            catch (Exception e)
            {
                // assert
                Assert.AreEqual(expected, e.Message);
            }
        }
        public void GetOrderedJobListTest_ConsistencyError()
        {
            // arrange
            var jobString  = "a=>a";
            var expected   = "Error: the job list is not coherent";
            var jobsSorter = JobsSorterBuilder.CreateJobsSorter();

            // act
            try
            {
                var actual = jobsSorter.GetOrderedJobList(jobString.ToUpper());
            }
            catch (Exception e)
            {
                // assert
                Assert.AreEqual(expected, e.Message);
            }
        }
        public void GetOrderedJobListTest_SyntaxError()
        {
            // arrange
            var jobString  = "a$b";
            var expected   = "Error: wrong syntax";
            var jobsSorter = JobsSorterBuilder.CreateJobsSorter();

            // act
            try
            {
                var actual = jobsSorter.GetOrderedJobList(jobString.ToUpper());
            }
            catch (Exception e)
            {
                // assert
                Assert.AreEqual(expected, e.Message);
            }
        }