public void DoWorkCallsAddsCorrectNumberOfFilenamesToCurrentTaskFromWfsServiceGetTargetFiles() { mockWfsService = new Mock <IWfsService>(); mockWfsService.Setup(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Guid.NewGuid()); mockWfsService.Setup(m => m.GetErrors(It.IsAny <Guid>())).Returns(new List <string>()); WfsService.JMServices.Job job = new WfsService.JMServices.Job() { Status = JobStatus.Completed }; mockWfsService.Setup(m => m.GetJob(It.IsAny <Guid>())).Returns(job); mockWfsService.Setup(m => m.GetTargetFiles(It.IsAny <Guid>())).Returns(new List <string> { "\\\\sdfsdfsdf\\sdfgsdf\\1", "\\\\sdfsdfsdf\\sdfgsdf\\2", "\\\\sdfsdfsdf\\sdfgsdf\\3" }); sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); Task.To.Path = "\\\\sdfsdfsdf\\sdfgsdf"; sut.Assign(Task); sut.Pulse(Task); Assert.That(sut.GetStatus().CurrentTask.To.Files.Count, Is.EqualTo(3)); }
public void DoWorkCallSetsCurrentTaskStateToFailedIfExceptionOrrurs() { mockWfsService = new Mock <IWfsService>(); mockWfsService.Setup(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Guid.NewGuid()); mockWfsService.Setup(m => m.GetErrors(It.IsAny <Guid>())).Returns(new List <string>()); WfsService.JMServices.Job job = new WfsService.JMServices.Job() { Status = JobStatus.Completed }; mockWfsService.Setup(m => m.GetJob(It.IsAny <Guid>())).Returns(job); mockWfsService.Setup(m => m.GetTargetFiles(It.IsAny <Guid>())).Returns(new List <string> { "\\\\sdfsdfsdf\\sdfgsdf\\1", "\\\\sdfsdfsdf\\sdfgsdf\\2", "\\\\sdfsdfsdf\\sdfgsdf\\3" }); sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); Task.To.Path = "\\\\NOT ALIKE AT ALL"; // Forces exception sut.Assign(Task); sut.Pulse(Task); Assert.That(Task.State, Is.EqualTo(ExecutionState.Failed)); }
public void DoWorkCallsWfsServiceGetTargetFilesIfExecutionStateIsDone() { mockWfsService = new Mock <IWfsService>(); mockWfsService.Setup(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Guid.NewGuid()); WfsService.JMServices.Job job = new WfsService.JMServices.Job() { Status = JobStatus.Completed }; mockWfsService.Setup(m => m.GetJob(It.IsAny <Guid>())).Returns(job); sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); sut.Assign(Task); sut.Pulse(Task); mockWfsService.Verify(m => m.GetTargetFiles(It.IsAny <Guid>()), Times.Once); }
public void DoWorkDoesNotCallWfsServiceGetTargetFilesIfExecutionStateIsNotDone(JobStatus jobStatus) { mockWfsService = new Mock <IWfsService>(); mockWfsService.Setup(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Guid.NewGuid()); WfsService.JMServices.Job job = new WfsService.JMServices.Job() { Status = jobStatus }; mockWfsService.Setup(m => m.GetJob(It.IsAny <Guid>())).Returns(job); mockWfsService.Setup(m => m.GetErrors(It.IsAny <Guid>())).Returns(new List <string>()); sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); sut.Assign(Task); sut.Pulse(Task); mockWfsService.Verify(m => m.GetTargetFiles(It.IsAny <Guid>()), Times.Never); }
public void DoWorkDoesSetsCurrentTaskStateToCorrectValue(JobStatus jobStatus, ExecutionState assertState) { mockWfsService = new Mock <IWfsService>(); mockWfsService.Setup(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Guid.NewGuid()); mockWfsService.Setup(m => m.GetErrors(It.IsAny <Guid>())).Returns(new List <string>()); WfsService.JMServices.Job job = new WfsService.JMServices.Job() { Status = jobStatus }; mockWfsService.Setup(m => m.GetJob(It.IsAny <Guid>())).Returns(job); sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); sut.Assign(Task); sut.Pulse(Task); Assert.That(Task.State, Is.EqualTo(assertState)); }
public void DoWorkDoesNotCallWfsServiceEnqueueJobIfForeignIsKeyNotEmpty(string foreignKey) { mockWfsService = new Mock <IWfsService>(); mockWfsService.Setup(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(Guid.NewGuid()); WfsService.JMServices.Job job = new WfsService.JMServices.Job() { Status = JobStatus.Active }; mockWfsService.Setup(m => m.GetJob(It.IsAny <Guid>())).Returns(job); Task.ForeignKey = foreignKey; sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); sut.Assign(Task); sut.Pulse(Task); mockWfsService.Verify(m => m.EnqueueJob(It.IsAny <Guid>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()), Times.Never); }
public void SetUp() { DynamicPlugin.ClearSiblings(Wfs.Wfs.Type); mockWfsService.Setup(m => m.GetWorkingNodes(It.IsAny <string>())).Returns(new string[1]); mockPresetProvider.Setup(m => m.AsList()).Returns(new List <WorkflowConfiguration> { new WorkflowConfiguration { AspectRatio = AspectRatio.ratio_16x9, BurnInLogo = false, Format = StateFormat.h264_od_standard, Workflow = Guid.NewGuid() } }); mockPresetProvider.SetupGet(m => m.MachineGroup).Returns("UnitTestGroup"); Plugin = sut = new Wfs.Wfs(_pluginUrn, MockTimeProvider.Object, Logging, mockWfsService.Object, mockPresetProvider.Object); Task = new ExecutionTask { From = new Essence() { Flags = StateFlags.None, Path = @"\\sdfsd\sdfsdf\sdfsfsd", Format = StateFormat.dv5p, AspectRatio = AspectRatio.ratio_16x9, Files = new List <EssenceFile> { "sdfsdfsdf.mov" }, Duration = 234234234 }, To = new Essence() { Flags = StateFlags.None, Path = @"\\sdfsdfsdf\sdgsdgsdg", Format = StateFormat.h264_od_standard, AspectRatio = AspectRatio.ratio_16x9, Files = new List <EssenceFile>() }, PluginUrn = _pluginUrn }; }