public void TestGoodRun()
        {
            var clientMock  = new Mock <IRSAPIClient>();
            var factoryMock = new Mock <IRelativityClientFactory>();
            var scriptExecutionRepositoryMock = new Mock <IRelativityScriptRepository>();

            factoryMock.Setup(m => m.GetRelativityClient(It.IsAny <ExecutionIdentity>())).Returns(clientMock.Object);
            factoryMock.Setup(m => m.GetRelativityClient()).Returns(clientMock.Object);

            var result = new RelativityScriptResult()
            {
                Success = true,
                Message = "unit test result"
            };

            scriptExecutionRepositoryMock
            .Setup(repo => repo.ExecuteRelativityScript(It.IsAny <RelativityScript>(), It.IsAny <List <RelativityScriptInput> >(), It.IsAny <RelativityWorkspace>())).Returns(result);

            clientMock.Setup(m => m.APIOptions).Returns(new APIOptions(-1));

            var jobScheduleRepositoryMock = new JobScheduleRepositoryMock();
            var scriptRunner = new RelativityScriptRunner(jobScheduleRepositoryMock.JobScheduleRepository, factoryMock.Object, scriptExecutionRepositoryMock.Object);

            var jobSchedule = jobScheduleRepositoryMock.CurrentJobSchedule;

            scriptRunner.ExecuteScriptJob(jobSchedule);

            Assert.That(jobSchedule.CurrentJobHistory.ResultText.Equals(result.Message));
            Assert.That(!jobSchedule.CurrentJobHistory.HasError);
            Assert.That(jobScheduleRepositoryMock.JobScheduleStarted && jobScheduleRepositoryMock.JobScheduleFinished);
        }
        public void TestExecptionThrown()
        {
            var clientMock  = new Mock <IRSAPIClient>();
            var factoryMock = new Mock <IRelativityClientFactory>();
            var scriptExecutionRepositoryMock = new Mock <IRelativityScriptRepository>();

            factoryMock.Setup(m => m.GetRelativityClient(It.IsAny <ExecutionIdentity>())).Returns(clientMock.Object);
            factoryMock.Setup(m => m.GetRelativityClient()).Returns(clientMock.Object);

            scriptExecutionRepositoryMock
            .Setup(repo => repo.ExecuteRelativityScript(It.IsAny <RelativityScript>(), It.IsAny <List <RelativityScriptInput> >(), It.IsAny <RelativityWorkspace>()))
            .Throws(new Exception("None shall pass"));

            clientMock.Setup(m => m.APIOptions).Returns(new APIOptions(-1));

            var jobScheduleRepositoryMock = new JobScheduleRepositoryMock();

            var scriptRunner = new RelativityScriptRunner(jobScheduleRepositoryMock.JobScheduleRepository, factoryMock.Object, scriptExecutionRepositoryMock.Object);
            var jobSchedule  = jobScheduleRepositoryMock.CurrentJobSchedule;

            scriptRunner.ExecuteScriptJob(jobSchedule);
            Assert.That(jobSchedule.CurrentJobHistory.HasError);
            Assert.That(jobScheduleRepositoryMock.JobScheduleStarted && jobScheduleRepositoryMock.JobScheduleFinished);
        }