public void VerifyDPICalculateParked()
        {
            //Arrange
            #region [ Variables ]

            DateTime now = DateTime.Now;
            DateTime startDateTime = new DateTime(2011, 08, 01, 12, 0, 0);
            DateTime startDateTime2 = startDateTime.AddDays(1);

            #endregion

            #region [ CallType Repository ]

            FakeObjectSet<CS_CallType> fakeCallTypeRepository = new FakeObjectSet<CS_CallType>();
            fakeCallTypeRepository.AddObject
                (
                    new CS_CallType()
                    {
                        ID = (int)Globals.CallEntry.CallType.Parked,
                        Description = "Parked",
                        Xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>  <DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">    <Controls>      <DynamicControls xsi:type=\"DynamicDatePickerXml\">        <Name>dtpDate</Name>        <IsValidEmpty>false</IsValidEmpty>        <EmptyValueMessage>The Parked Date field is required</EmptyValueMessage>        <InvalidValueMessage>Invalid Parked Date format</InvalidValueMessage>        <DateTimeFormat>Default</DateTimeFormat>        <ShowOn>Both</ShowOn>        <ValidationGroup>CallEntry</ValidationGroup>        <Label>          <Text>Parked Date:</Text>          <Css>dynamicLabel</Css>        </Label>      </DynamicControls>      <DynamicControls xsi:type=\"DynamicTimeXml\">        <Name>txtTime</Name>        <IsValidEmpty>false</IsValidEmpty>        <ValidationGroup>CallEntry</ValidationGroup>        <EmptyValueMessage>The Parked Time field is required.</EmptyValueMessage>        <InvalidValueMessage>The Parked Time field is invalid</InvalidValueMessage>        <MaskedType>Time</MaskedType>        <Mask>99:99</Mask>        <Label>          <Text>Parked Time:</Text>          <Css>dynamicLabel</Css>        </Label>      </DynamicControls>      <DynamicControls xsi:type=\"DynamicCountableTextBoxXml\">        <Name>txtNote</Name>        <IsRequired>false</IsRequired>        <MaxChars>255</MaxChars>        <MaxCharsWarning>250</MaxCharsWarning>        <TextMode>MultiLine</TextMode>        <Width>300</Width>        <Height>150</Height>        <Label>          <Text>Note:</Text>          <Css>dynamicLabel</Css>        </Label>      </DynamicControls>    </Controls>  </DynamicFieldsAggregator>",
                        CallCriteria = false,
                        IsAutomaticProcess = false,
                        DpiStatus = 2,
                        Active = true
                    }
                );

            #endregion

            #region [ Resource Repository ]

            FakeObjectSet<CS_Resource> fakeResourceRepository = new FakeObjectSet<CS_Resource>();
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 1, EmployeeID = 1, EquipmentID = null, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 2, EmployeeID = null, EquipmentID = 1, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 3, EmployeeID = null, EquipmentID = 2, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 4, EmployeeID = null, EquipmentID = 3, JobID = 1, Duration = 1, StartDateTime = startDateTime2, Active = true });

            #endregion

            #region [ DPI Repository ]

            FakeObjectSet<CS_DPI> fakeDPIRepository = new FakeObjectSet<CS_DPI>();
            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 1,
                Date = startDateTime.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true,
                    }
                }
            });

            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 2,
                Date = startDateTime2.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 3,
                        Active = true
                    }
                }
            });

            #endregion

            #region [ Parameters ]

            CS_CallLog callLog = new CS_CallLog()
            {
                CallTypeID = (int)Globals.CallEntry.CallType.Parked,
                Xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Release Date:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>2011-08-01T00:00:00</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Release Date field is required</EmptyValueMessage><InvalidValueMessage>Invalid Release Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Release Time:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>12:00</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Release Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Release Time field is required.</EmptyValueMessage></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>",
                CreationDate = now,
                CallDate = now,
                JobID = 1
            };

            List<int> employeeIDList = new List<int>() { 1 };
            List<int> equipmentIDList = new List<int>() { 1, 2, 3 };

            #endregion

            #region [ Mock ]

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPI>()).Returns(fakeDPIRepository);
            CallLogModel model = new CallLogModel(mockUnitOfWork.Object);

            #endregion

            //Act
            model.VerifyDPICalculate(callLog, employeeIDList, equipmentIDList);

            //Assert
            CS_DPI dpi = fakeDPIRepository.FirstOrDefault(e => e.ID == 1);
            CS_DPI dpi2 = fakeDPIRepository.FirstOrDefault(e => e.ID == 2);
            Assert.IsTrue(dpi.Calculate, "Fail at Calculate True");
            Assert.IsFalse(dpi2.Calculate, "Fail at Calculate False");
        }
        public void VerifyDPICalculateAdded()
        {
            //Arrange
            #region [ Variables ]

            DateTime now = DateTime.Now;
            DateTime startDateTime = new DateTime(2011, 08, 01, 12, 0, 0);
            DateTime startDateTime2 = startDateTime.AddDays(1);

            #endregion

            #region [ CallType Repository ]

            FakeObjectSet<CS_CallType> fakeCallTypeRepository = new FakeObjectSet<CS_CallType>();
            fakeCallTypeRepository.AddObject
                (
                    new CS_CallType()
                    {
                        ID = 27,
                        Description = "Added Resource",
                        Xml = string.Empty,
                        CallCriteria = true,
                        IsAutomaticProcess = true,
                        DpiStatus = 1,
                        Active = true
                    }
                );

            #endregion

            #region [ Resource Repository ]

            FakeObjectSet<CS_Resource> fakeResourceRepository = new FakeObjectSet<CS_Resource>();
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 1, EmployeeID = 1, EquipmentID = null, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 2, EmployeeID = null, EquipmentID = 1, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 3, EmployeeID = null, EquipmentID = 2, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true });
            fakeResourceRepository.AddObject(new CS_Resource() { ID = 4, EmployeeID = null, EquipmentID = 3, JobID = 1, Duration = 1, StartDateTime = startDateTime2, Active = true });

            #endregion

            #region [ DPI Repository ]

            FakeObjectSet<CS_DPI> fakeDPIRepository = new FakeObjectSet<CS_DPI>();
            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 1,
                Date = startDateTime.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true,
                    }
                }
            });

            fakeDPIRepository.AddObject(new CS_DPI()
            {
                ID = 2,
                Date = startDateTime2.Date,
                Calculate = false,
                ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved,
                JobID = 1,
                IsContinuing = true,
                ProcessStatusDate = DateTime.Now,
                CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF,
                Total = 1000,
                CreatedBy = "System",
                //CreationID =,
                CreationDate = DateTime.Now,
                ModifiedBy = "System",
                //ModificationID,
                ModificationDate = DateTime.Now,
                Active = true,
                CS_DPIResource = new EntityCollection<CS_DPIResource>()
                {
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EmployeeID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 1,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 2,
                        Active = true
                    },
                    new CS_DPIResource()
                    {
                        ID = 1,
                        DPIID = 1,
                        EquipmentID = 3,
                        Active = true
                    }
                }
            });

            #endregion

            #region [ Parameters ]

            CS_CallLog callLog = new CS_CallLog()
            {
                CallTypeID = (int)Globals.CallEntry.CallType.AddedResource,
                CreationDate = now,
                CallDate = now,
                JobID = 1
            };

            List<int> employeeIDList = new List<int>() { 1 };
            List<int> equipmentIDList = new List<int>() { 1, 2 };

            #endregion

            #region [ Mock ]

            Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>();
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceRepository);
            mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPI>()).Returns(fakeDPIRepository);
            CallLogModel model = new CallLogModel(mockUnitOfWork.Object);

            #endregion

            //Act
            model.VerifyDPICalculate(callLog, employeeIDList, equipmentIDList);

            //Assert
            CS_DPI dpi = fakeDPIRepository.FirstOrDefault(e => e.ID == 1);
            CS_DPI dpi2 = fakeDPIRepository.FirstOrDefault(e => e.ID == 2);
            Assert.IsTrue(dpi.Calculate, "Fail at Calculate True");
            Assert.IsFalse(dpi2.Calculate, "Fail at Calculate False");
        }