コード例 #1
0
        public void TestListPresetNotification()
        {
            // Arrange
            FakeObjectSet<CS_Job> fakeJobObject = new FakeObjectSet<CS_Job>();
            fakeJobObject.AddObject(
                new CS_Job
                {
                    Active = true,
                    ID = 243,
                    Number = "123",
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 243,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus() { JobID = 243, JobStatusId = (int)Globals.JobRecord.JobStatus.Preset, Active = true }
                        }
                    },
                    CS_PresetInfo = new CS_PresetInfo()
                    {
                        JobId = 243,
                        Date = new DateTime(2011, 6, 15),
                        Time = new TimeSpan(16, 0, 0),
                        Active = true
                    }
                }
                );
            fakeJobObject.AddObject(
                new CS_Job
                {
                    Active = true,
                    ID = 244,
                    Number = "124",
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 244,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus() { JobID = 244, JobStatusId = (int)Globals.JobRecord.JobStatus.PresetPurchase, Active = true }
                        }
                    },
                    CS_PresetInfo = new CS_PresetInfo()
                    {
                        JobId = 244,
                        Date = new DateTime(2011, 6, 15),
                        Time = new TimeSpan(12, 0, 0),
                        Active = true
                    }
                }
                );
            fakeJobObject.AddObject(
                new CS_Job
                {
                    Active = true,
                    ID = 245,
                    Number = "125",
                    CS_JobInfo = new CS_JobInfo()
                    {
                        JobID = 245,
                        CS_Job_JobStatus = new EntityCollection<CS_Job_JobStatus>()
                        {
                            new CS_Job_JobStatus() { JobID = 245, JobStatusId = (int)Globals.JobRecord.JobStatus.Active, Active = true }
                        }
                    },
                    CS_PresetInfo = new CS_PresetInfo()
                }
                );

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(w => w.CreateObjectSet<CS_Job>()).Returns(fakeJobObject);

            // Act
            JobModel jobModel = new JobModel(mockUnitOfWork.Object);
            IList<PresetNotificationVO> returnList = jobModel.ListPresetNotification(new DateTime(2011, 6, 16, 16, 32, 0));

            // Assert
            Assert.AreEqual(2, returnList.Count);
        }
コード例 #2
0
 public void GetPresetNotificationList()
 {
     try
     {
         using (_jobModel = new JobModel())
         {
             _view.PresetNotificationList = _jobModel.ListPresetNotification(DateTime.Now);
         }
     }
     catch (Exception ex)
     {
         if (null != ex.InnerException)
             Logger.Write(string.Format("An error has occurred while trying to get the Preset Notification LIst\n{0}\n{1}\n{2}\n{3}", ex.Message, ex.StackTrace, ex.InnerException.Message, ex.InnerException.StackTrace));
         else
             Logger.Write(string.Format("An error has occurred while trying to get the Preset Notification LIst\n{0}\n{1}", ex.Message, ex.StackTrace));
     }
 }