Exemplo n.º 1
0
        public void GetJobStatusCountTest()
        {
            var userID = "UserIDTest";
            var job1   = new Job
            {
                AppID   = AppID,
                UserID  = userID,
                Created = DateTime.Now,
                Status  = null
            };

            job1 = jobDAL.SetJob(job1);
            Assert.True(!string.IsNullOrWhiteSpace(job1.JobID));

            //status != null
            var job2 = new Job
            {
                AppID   = AppID,
                UserID  = userID,
                Created = DateTime.Now,
                Status  = JobStatus.Stopped
            };

            job2 = jobDAL.SetJob(job2);
            Assert.True(!string.IsNullOrWhiteSpace(job2.JobID));

            var statusCounts = jobDAL.GetJobStatusCount(null, null);

            jobDAL.Delete(new List <string> {
                job1.JobID, job2.JobID
            });

            var jobStatuses = statusCounts.Select(s => s.Status).ToList();

            Assert.True(jobStatuses.Contains(null));
            Assert.True(jobStatuses.Contains(JobStatus.Stopped));
            Assert.True(statusCounts.Count >= 2);
            foreach (var jobStatusCount in statusCounts)
            {
                if (jobStatusCount.Status == null)
                {
                    Assert.True(jobStatusCount.NullCount >= 1);
                }
                if (jobStatusCount.Status == JobStatus.Stopped)
                {
                    Assert.True(jobStatusCount.Count >= 1);
                }
            }
        }