public void TestGetDataRequestIsCalledWithCOrrectDateRange() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var personPunchRounds = new List <PersonPunchRound> { new PersonPunchRound() }; CommandExecutor.Setup( w => w.Execute <PersonPunchRoundCriteria, List <PersonPunchRound> >(It.IsAny <PersonPunchRoundCriteria>())) .Returns(personPunchRounds); CommandExecutor.Setup(w => w.Execute <PunchRoundExportData>(It.IsAny <PunchRoundExportData>())); var status = Job.Run(criteria); CommandExecutor.Verify(m => m.Execute <PersonPunchRoundCriteria, List <PersonPunchRound> > (It.Is <PersonPunchRoundCriteria>(t => t.StartDate == criteria.StartDate && t.EndDate == criteria.StartDate.AddDays(63))), Times.Once); CommandExecutor.Verify(m => m.Execute <PunchRoundExportData> (It.Is <PunchRoundExportData>(p => p.PersonPunchRounds == personPunchRounds)), Times.Once); Assert.AreEqual(JobStatus.Success, status); }
public void JobIsCompletedWithWarningIfThereIsAtLeastOneWarining() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var data = new TimesheetReadCommandResult <List <ChangePunch> >() { Data = new List <ChangePunch> { new ChangePunch { Date = new DateTime(2017, 4, 16) } }, Warnings = new List <TimesheetValidationType> { TimesheetValidationType.PunchEmptyDay } }; CommandExecutor.Setup(w => w.Execute <TimesheetExtractOutputData, TimesheetReadCommandResult <List <ChangePunch> > >(It.IsAny <TimesheetExtractOutputData>())).Returns(data); var jobStatus = Job.Run(criteria); Assert.AreEqual(JobStatus.SuccessWithWarnings, jobStatus); }
public void JobFailsIfPersonNumbersAreNull() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; CommandExecutor.Setup(w => w.Execute <WtkProfileExtractOutputData, List <WtkProfile> >(It.IsAny <WtkProfileExtractOutputData>())).Returns(new List <WtkProfile>()); var jobStatus = Job.Run(criteria); Assert.AreEqual(JobStatus.SuccessWithWarnings, jobStatus); }
public void TestJobIsCompletedSuccessfullyIfAnExceptionOccursDuringScheduleRemoving() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var exception = new RemoveTimesheetItemException(null, null, TimesheetItemType.Schedule); CommandExecutor.Setup(w => w.Execute <List <PersonSchedule> >(It.IsAny <List <PersonSchedule> >())).Throws(exception); var jobStatus = Job.Run(criteria); Assert.AreEqual(JobStatus.Success, jobStatus); }
protected void JobThrowsDependentJobWasNotRunException() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var exception = new FileNotExistException("fileName", null); CommandExecutor.Setup(w => w.Execute <WtkProfileExtractOutputData, List <WtkProfile> >(It.IsAny <WtkProfileExtractOutputData>())) .Throws(exception); Assert.Throws <DependentJobWasNotRunException>(() => Job.Run(criteria)); }
protected void JobThrowsSourceFileWasNotFoundException() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var exception = new FileNotExistException("fileName", null); CommandExecutor.Setup(w => w.Execute <TimesheetExtractOutputData, TimesheetReadCommandResult <List <ChangePunch> > >(It.IsAny <TimesheetExtractOutputData>())).Throws(exception); Assert.Throws <SourceFileWasNotFoundException>(() => Job.Run(criteria)); }
public void JobIsCompletedWithWarningIfThereAreNoPunchDataToProcess() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var data = new TimesheetReadCommandResult <List <ChangePunch> >() { Data = new List <ChangePunch>() }; CommandExecutor.Setup(w => w.Execute <TimesheetExtractOutputData, TimesheetReadCommandResult <List <ChangePunch> > >(It.IsAny <TimesheetExtractOutputData>())).Returns(data); var jobStatus = Job.Run(criteria); Logger.Verify(m => m.Warn("There are no valid punches", It.IsAny <string>(), null)); Assert.AreEqual(JobStatus.SuccessWithWarnings, jobStatus); }
private void InitiatePunchRoundTestJob(int jobNumber) { SetUpXmlApiSettings(); IParameterisedJob <PunchRoundTestCriteria> job = null; var jobStatusTracker = Program.Container.Resolve <JobStatusTracker>(); switch (jobNumber) { case 1: job = new PopulatePunchRoundTestDataJob(_commandExecutor, _outputFileDictionary, jobStatusTracker, _logger); break; case 2: job = new GatherPunchRoundTestTimesheetJob(_commandExecutor, _outputFileDictionary, jobStatusTracker, _logger); break; case 3: job = new CleanUpPunchRoundTestDataJob(_commandExecutor, _outputFileDictionary, jobStatusTracker, _logger); break; } DateTime startDate; DateTime.TryParse(mtbPunchRoundTestStartDate.Text, out startDate); var criteria = new PunchRoundTestCriteria { StartDate = startDate }; try { ExecuteJob <PunchRoundTestCriteria>(job, criteria); } catch (DateOutOfRangeValidationException ex) { MessageBox.Show(string.Format(ToolUI.MsgInvalidDateRange, ex.Filename, ex.StartDate.ToString(DateFormat), ex.EndDate.ToString(DateFormat))); } }
public void JobFailsIfThereScheduleDataIsOutOfDateRangeToProcess() { var criteria = new PunchRoundTestCriteria() { StartDate = new DateTime(2017, 4, 10) }; var scheduleDataResult = new TimesheetReadCommandResult <List <ChangeSchedule> >() { Data = new List <ChangeSchedule>() { new ChangeSchedule { StartDate = new DateTime(2016, 1, 1) }, new ChangeSchedule { EndDate = new DateTime(2018, 1, 1) } } }; CommandExecutor.Setup(w => w.Execute <TimesheetExtractOutputData, TimesheetReadCommandResult <List <ChangeSchedule> > >(It.IsAny <TimesheetExtractOutputData>())).Returns(scheduleDataResult); Assert.Throws <DateOutOfRangeValidationException>(() => Job.Run(criteria)); }