Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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));
        }
Esempio n. 6
0
        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);
        }