Exemplo n.º 1
0
        public void ServerSchedulerFactory_CreateResource()
        {
            var service = new Mock <IDev2TaskService>();

            var cFactory = new Mock <ITaskServiceConvertorFactory>();

            cFactory.Setup(f => f.CreateExecAction("notepad", null, null))

            .Returns(new Dev2ExecAction(new TaskServiceConvertorFactory(), new ExecAction("notepad.exe", null, null)));

            var mockTask = new Mock <IDev2TaskDefinition>();

            mockTask.Setup(a => a.AddAction(It.IsAny <IAction>()));
            mockTask.Setup(a => a.AddTrigger(It.IsAny <ITrigger>()));
            mockTask.Setup(a => a.XmlText).Returns("bob");
            service.Setup(a => a.NewTask()).Returns(mockTask.Object);

            var factory = new ServerSchedulerFactory(service.Object, cFactory.Object, new Mock <IDirectoryHelper>().Object, a => a.WorkflowName);
            var trig    = new DailyTrigger();
            var res     = factory.CreateResource("A", SchedulerStatus.Disabled, trig, "c", Guid.NewGuid().ToString());

            Assert.AreEqual("A", res.Name);
            Assert.AreEqual(SchedulerStatus.Disabled, res.Status);

            Assert.AreEqual("c", res.WorkflowName);
        }
        public void ServerSchedulerFactory_Default()
        {

#pragma warning disable 168
            var factory = new ServerSchedulerFactory();
#pragma warning restore 168

        }
Exemplo n.º 3
0
        public void ServerSchedulerFactory_CreateModel()
        {
            var service  = new Mock <IDev2TaskService>().Object;
            var cFactory = new Mock <ITaskServiceConvertorFactory>().Object;
            var factory  = new ServerSchedulerFactory(service, cFactory, new DirectoryHelper(), a => a.WorkflowName);
            var model    = (ScheduledResourceModel)factory.CreateModel("bob", new SecurityWrapper(ServerAuthorizationService.Instance));

            Assert.AreEqual("bob", model.WarewolfFolderPath);
            Assert.IsTrue(model.WarewolfAgentPath.Contains(GlobalConstants.SchedulerAgentPath));
            Assert.IsTrue(model.DebugHistoryPath.Contains(GlobalConstants.SchedulerDebugPath));
        }
 public void ServerSchedulerFactory_Constructor()
 {
     IDev2TaskService service = new Mock<IDev2TaskService>().Object;
     ITaskServiceConvertorFactory cFactory = new Mock<ITaskServiceConvertorFactory>().Object;
     var dir = new Mock<IDirectoryHelper>();
     dir.Setup(a => a.CreateIfNotExists(It.IsAny<string>())).Verifiable();
     var factory = new ServerSchedulerFactory(service, cFactory, dir.Object);
     Assert.AreEqual(cFactory, factory.ConvertorFactory);
     Assert.AreEqual(service, factory.TaskService);
     dir.Verify(a => a.CreateIfNotExists(It.IsAny<string>()));
 }
Exemplo n.º 5
0
        static void CheckTriggerTypes(Trigger t)
        {
            IDev2TaskService             s    = new Dev2TaskService(new TaskServiceConvertorFactory());
            ITaskServiceConvertorFactory fact = new TaskServiceConvertorFactory();
            var schedulerFactory = new ServerSchedulerFactory(s, fact, new DirectoryHelper(), a => a.WorkflowName);


            var trig = schedulerFactory.CreateTrigger(t);

            Assert.AreEqual(t.TriggerType, trig.Trigger.TriggerType);
            Assert.AreEqual(t.ToString(), trig.Trigger.ToString());
        }
Exemplo n.º 6
0
        public void ServerSchedulerFactory_Dispose()
        {
            var service  = new Mock <IDev2TaskService>();
            var cFactory = new Mock <ITaskServiceConvertorFactory>().Object;
            var dir      = new Mock <IDirectoryHelper>();

            dir.Setup(a => a.CreateIfNotExists(It.IsAny <string>())).Verifiable();
            var factory = new ServerSchedulerFactory(service.Object, cFactory, dir.Object, a => a.WorkflowName);

            service.Setup(a => a.Dispose()).Verifiable();
            factory.Dispose();
            service.Verify(a => a.Dispose());
        }
Exemplo n.º 7
0
        public void ServerSchedulerFactory_Constructor()
        {
            var service  = new Mock <IDev2TaskService>().Object;
            var cFactory = new Mock <ITaskServiceConvertorFactory>().Object;
            var dir      = new Mock <IDirectoryHelper>();

            dir.Setup(a => a.CreateIfNotExists(It.IsAny <string>())).Verifiable();
            var factory = new ServerSchedulerFactory(service, cFactory, dir.Object, a => a.WorkflowName);

            Assert.AreEqual(cFactory, factory.ConvertorFactory);
            Assert.AreEqual(service, factory.TaskService);
            dir.Verify(a => a.CreateIfNotExists(It.IsAny <string>()));
        }
        public void ServerSchedulerFactory_Dispose()
        {

            var service = new Mock<IDev2TaskService>();
            ITaskServiceConvertorFactory cFactory = new Mock<ITaskServiceConvertorFactory>().Object;
            var dir = new Mock<IDirectoryHelper>();
            dir.Setup(a => a.CreateIfNotExists(It.IsAny<string>())).Verifiable();
            var factory = new ServerSchedulerFactory(service.Object, cFactory, dir.Object);
            service.Setup(a => a.Dispose()).Verifiable();
            factory.Dispose();
            service.Verify(a => a.Dispose());

        }
Exemplo n.º 9
0
        public void ServerSchedulerFactory_Default()
        {
#pragma warning disable 168
            var factory = new ServerSchedulerFactory(a => a.WorkflowName);
#pragma warning restore 168
        }
        public void ServerSchedulerFactory_CreateModel()
        {
            IDev2TaskService service = new Mock<IDev2TaskService>().Object;
            ITaskServiceConvertorFactory cFactory = new Mock<ITaskServiceConvertorFactory>().Object;
            var factory = new ServerSchedulerFactory(service, cFactory, new DirectoryHelper());
            ScheduledResourceModel model = (ScheduledResourceModel)factory.CreateModel("bob", new SecurityWrapper(ServerAuthorizationService.Instance));
            Assert.AreEqual("bob", model.WarewolfFolderPath);
            Assert.IsTrue(model.WarewolfAgentPath.Contains(GlobalConstants.SchedulerAgentPath));
            Assert.IsTrue(model.DebugHistoryPath.Contains(GlobalConstants.SchedulerDebugPath));

        }
        private static void CheckTriggerTypes(Trigger t)
        {
            IDev2TaskService s = new Dev2TaskService(new TaskServiceConvertorFactory());
            ITaskServiceConvertorFactory fact = new TaskServiceConvertorFactory();
            ServerSchedulerFactory schedulerFactory = new ServerSchedulerFactory(s, fact, new DirectoryHelper());


            var trig = schedulerFactory.CreateTrigger(t);
            Assert.AreEqual(t.TriggerType, trig.Trigger.TriggerType);
            Assert.AreEqual(t.ToString(), trig.Trigger.ToString());
        }
        public void ServerSchedulerFactory_CreateResource()
        {
            var service = new Mock<IDev2TaskService>();

            var cFactory = new Mock<ITaskServiceConvertorFactory>();
            cFactory.Setup(f => f.CreateExecAction("notepad", null, null))
// ReSharper disable RedundantArgumentDefaultValue
                .Returns(new Dev2ExecAction(new TaskServiceConvertorFactory(), new ExecAction("notepad.exe", null, null)));
// ReSharper restore RedundantArgumentDefaultValue
            var mockTask = new Mock<IDev2TaskDefinition>();
            mockTask.Setup(a => a.AddAction(It.IsAny<IAction>()));
            mockTask.Setup(a => a.AddTrigger(It.IsAny<ITrigger>()));
            mockTask.Setup(a => a.XmlText).Returns("bob");
            service.Setup(a => a.NewTask()).Returns(mockTask.Object);

            var factory = new ServerSchedulerFactory(service.Object, cFactory.Object, new Mock<IDirectoryHelper>().Object);
            var trig = new DailyTrigger();
            var res = factory.CreateResource("A", SchedulerStatus.Disabled, trig, "c");
            Assert.AreEqual("A", res.Name);
            Assert.AreEqual(SchedulerStatus.Disabled, res.Status);

            Assert.AreEqual("c", res.WorkflowName);
        }