public void MustFillSpecialPricingInfoWhenCloningJobInfo()
        {
            //Arrange
            Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
            mockJobInfoView.SetupProperty(e => e.CloningId, 1);
            mockJobInfoView.SetupProperty(e => e.SpecialPricingEntity, null);
            Mock<JobModel> mockJobModel = new Mock<JobModel>();
            mockJobModel.Setup(e => e.GetSpecialPricing(1)).Returns(new CS_SpecialPricing() { JobId = 1 });

            JobInfoPresenter presenter = new JobInfoPresenter(mockJobInfoView.Object, mockJobModel.Object);
            //Act
            presenter.LoadSpecialPricingInfoCloning();
            //Assert
            Assert.IsNotNull(mockJobInfoView.Object.SpecialPricingEntity);
        }
 public void WhenCloningJobInfoCallDateAndTimeMustBeSetToCurrent()
 {
     //Arrange
     Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
     mockJobInfoView.SetupProperty(e => e.JobInfoEntity, null);
     mockJobInfoView.SetupProperty(e => e.CloningId, 1);
     Mock<JobModel> mockJobModel = new Mock<JobModel>();
     mockJobModel.Setup(e => e.GetJobInfoWithAppend(1)).Returns(new CS_JobInfo() { JobID = 1, InitialCallDate = new DateTime(2000, 11, 05), InitialCallTime = new TimeSpan(1, 20, 5) });
     JobInfoPresenter presenter = new JobInfoPresenter(mockJobInfoView.Object,mockJobModel.Object);
     //Act
     presenter.LoadJobInfoCloningData();
     //Assert
     Assert.AreEqual(mockJobInfoView.Object.JobInfoEntity.InitialCallDate.Year, DateTime.Now.Year);
     Assert.AreEqual(mockJobInfoView.Object.JobInfoEntity.InitialCallDate.Month, DateTime.Now.Month);
     Assert.AreEqual(mockJobInfoView.Object.JobInfoEntity.InitialCallDate.Day, DateTime.Now.Day);
     Assert.AreEqual(mockJobInfoView.Object.JobInfoEntity.InitialCallTime.Hours, DateTime.Now.TimeOfDay.Hours);
     Assert.AreEqual(mockJobInfoView.Object.JobInfoEntity.InitialCallTime.Minutes, DateTime.Now.TimeOfDay.Minutes);
 }
Ejemplo n.º 3
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            _presenter = new JobInfoPresenter(this);

            if (!this.CustomerSpecificInfoXML.Equals(string.Empty))
            {
                _presenter.GetFieldsFromXml();
            }
        }
 public void WhenCloningJobInfoDescriptiveActionMustBeBlank()
 {
     //Arrange
     Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
     mockJobInfoView.SetupProperty(e => e.JobInfoEntity, null);
     mockJobInfoView.SetupProperty(e => e.CloningId, 1);
     Mock<JobModel> mockJobModel = new Mock<JobModel>();
     mockJobModel.Setup(e => e.GetJobInfoWithAppend(1)).Returns(new CS_JobInfo()
     {
         JobID = 1,
         CS_JobAction = new CS_JobAction()
             {
                 Description = "Action Description"
             }
     });
     JobInfoPresenter presenter = new JobInfoPresenter(mockJobInfoView.Object, mockJobModel.Object);
     //Act
     presenter.LoadJobInfoCloningData();
     //Assert
     Assert.IsNotNull(mockJobInfoView.Object.JobInfoEntity.CS_JobAction);
 }
 public void WhenCloningJobInfoCustomerSpecificInfoMustBeBlank()
 {
     //Arrange
     Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
     mockJobInfoView.SetupProperty(e => e.JobInfoEntity, null);
     mockJobInfoView.SetupProperty(e => e.CloningId, 1);
      Mock<JobModel> mockJobModel = new Mock<JobModel>();
      mockJobModel.Setup(e => e.GetJobInfoWithAppend(1)).Returns(new CS_JobInfo()
     {
         JobID = 1,
         CustomerSpecificInfo = "customer specific info"
     });
     JobInfoPresenter presenter = new JobInfoPresenter(mockJobInfoView.Object,mockJobModel.Object);
     //Act
     presenter.LoadJobInfoCloningData();
     //Assert
     Assert.IsTrue(string.IsNullOrEmpty(mockJobInfoView.Object.JobInfoEntity.CustomerSpecificInfo));
 }
        public void WhenJobCloningUsesTheAlreadyCreatedMethodToLoadJobInfoFieldsInModel()
        {
            //Arrange
            Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
            mockJobInfoView.SetupProperty(e => e.JobInfoEntity, null);
            mockJobInfoView.SetupProperty(e => e.CloningId, 1);
            Mock<JobModel> mockJobModel = new Mock<JobModel>();
            mockJobModel.Setup(e => e.GetJobInfoWithAppend(1)).Returns(new CS_JobInfo() { JobID = 1, Active = true });

            JobInfoPresenter presenter = new JobInfoPresenter(mockJobInfoView.Object, mockJobModel.Object);
            //Act
            presenter.LoadJobInfoCloningData();
            //Assert
            mockJobModel.Verify(e => e.GetJobInfoWithAppend(1), Times.Once());
        }
 public void WhenCloningJobInfoPresetInfoMustBeBlank()
 {
     //Arrange
     Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
     mockJobInfoView.SetupProperty(e => e.JobInfoEntity, null);
     mockJobInfoView.SetupProperty(e => e.CloningId, 1);
     Mock<JobModel> mockJobModel = new Mock<JobModel>();
     mockJobModel.Setup(e => e.GetPresetInfo(1)).Returns(new CS_PresetInfo()
     {
          JobId = 1
     });
     JobInfoPresenter  presenter = new JobInfoPresenter(mockJobInfoView.Object, mockJobModel.Object);
     //Act
     presenter.LoadJobInfoCloningData();
     //Assert
     Assert.IsNull(mockJobInfoView.Object.PresetInfoEntity);
 }
        public void WhenCloningJobInfoMustExcludeAllDivisionsExceptPrimaryDivision()
        {
            //Arrange
            Mock<IJobInfoView> mockJobInfoView = new Mock<IJobInfoView>();
            mockJobInfoView.SetupProperty(e => e.CloningId, 1);
            mockJobInfoView.SetupProperty(e => e.JobDivisionEntityList, null);
            Mock<JobModel> mockJobModel = new Mock<JobModel>();
            mockJobModel.Setup(e => e.ListJobDivision(1)).Returns(
                    new List<CS_JobDivision>()
                    {
                        new CS_JobDivision(){ ID=1, Active = true, PrimaryDivision = false},
                        new CS_JobDivision(){ ID=2, Active = true, PrimaryDivision = false},
                        new CS_JobDivision(){ ID=3, Active = true, PrimaryDivision = true}
                    }
                );

            JobInfoPresenter presenter = new JobInfoPresenter(mockJobInfoView.Object, mockJobModel.Object);
            //Act
            presenter.LoadJobDivisionCloning();
            //Assert
            Assert.IsNotNull(mockJobInfoView.Object.JobDivisionEntityList);
            Assert.AreEqual(1, mockJobInfoView.Object.JobDivisionEntityList.Count);
        }