public void DoesInstanceConnect() { QuartzAdmin.web.Models.InstanceRepository instanceRepo = new QuartzAdmin.web.Models.InstanceRepository(); QuartzAdmin.web.Models.InstanceModel instance = instanceRepo.GetInstance("Instance1"); try { Quartz.IScheduler sched = instance.GetQuartzScheduler(); Assert.IsNotNull(sched); } catch (Exception ex) { Assert.Fail("Error connecting", ex); } }
public ActionResult Create(FormCollection collection) { Models.InstanceModel instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = collection["InstanceName"]; foreach (string key in collection.Keys) { if (key.Contains("InstancePropertyKey") && collection[key].Length > 0) { string propIdx = key.Replace("InstancePropertyKey-", ""); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() {ParentInstance=instance, PropertyName = collection[key], PropertyValue = collection["InstancePropertyValue-" + propIdx.ToString()] }); } } this.Repository.Save(instance); return RedirectToAction("Index"); }
public void ShouldInstanceNameBeNull() { Story instanceNameStory = new Story("Should instance name be null"); QuartzAdmin.web.Models.InstanceModel instance = null; instanceNameStory .AsA("System Admin") .IWant("to create a new quartz instance") .SoThat("I can administer it using this tool"); instanceNameStory .WithScenario("Create new instance with null name") .Given("The instance name is", null, delegate(string instanceName) { instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = instanceName; }) .And("The instance has properties", delegate(){ instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "Hello", PropertyValue = "World" }); }) .When("the instance is validated") .Then("the validation should fail", delegate() { Assert.IsFalse(instance.IsValid()); }); instanceNameStory .WithScenario("Create new instance name and with no properties") .Given("The instance name is", null, delegate(string instanceName) { instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = instanceName; }) .And("The instance has properties", delegate() { instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "Hello", PropertyValue = "World" }); }) .When("the instance is validated") .Then("the validation should fail", delegate() { Assert.IsFalse(instance.IsValid()); }); }
public void DoesInstanceConnect2() { Story instanceConnectStory = new Story("Connect to instance"); QuartzAdmin.web.Models.InstanceRepository instanceRepo = new QuartzAdmin.web.Models.InstanceRepository(); QuartzAdmin.web.Models.InstanceModel instance = null; Quartz.IScheduler sched = null; instanceConnectStory .AsA("System Admin") .IWant("to connect to a running quartz instance") .SoThat("I can perform admin functions"); instanceConnectStory .WithScenario("Perform connection to instance") .Given("the instance name is", "Instance1", delegate(string instanceName) { instance = instanceRepo.GetInstance(instanceName); }) .When("the connection is attempted", delegate() { sched = instance.GetQuartzScheduler(); }) .Then("the connection is not null", delegate() { Assert.IsNotNull(sched); }); }
public ActionResult Create(FormCollection collection) { Models.InstanceModel instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = collection["InstanceName"]; foreach (string key in collection.Keys) { if (key.Contains("InstancePropertyKey") && collection[key].Length > 0) { string propIdx = key.Replace("InstancePropertyKey-", ""); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { ParentInstance = instance, PropertyName = collection[key], PropertyValue = collection["InstancePropertyValue-" + propIdx.ToString()] }); } } this.Repository.Save(instance); return(RedirectToAction("Index")); }
private QuartzAdmin.web.Models.InstanceModel GetTestInstance() { QuartzAdmin.web.Models.InstanceModel instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = "MyTestInstance"; instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.scheduler.instanceName", PropertyValue = "SampleQuartzScheduler" }); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.threadPool.type", PropertyValue = "Quartz.Simpl.SimpleThreadPool, Quartz" }); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.scheduler.proxy", PropertyValue = "true" }); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.scheduler.proxy.address", PropertyValue = "tcp://localhost:567/QuartzScheduler" }); return(instance); }
public void List_all_triggers_in_an_instance() { // Arrange QuartzAdmin.web.Controllers.InstanceController controller = GetInstanceController(); QuartzAdmin.web.Models.InstanceModel instance = GetTestInstance(); controller.Repository.Save(instance); // Act ActionResult result = controller.Connect(instance.InstanceName); int countOfTriggers = 0; if (result is ViewResult) { if (((ViewResult)result).ViewData.Model is QuartzAdmin.web.Models.InstanceViewModel) { countOfTriggers = ((QuartzAdmin.web.Models.InstanceViewModel)((ViewResult)result).ViewData.Model).Triggers.Count; } } // Assert Assert.IsTrue(countOfTriggers > 0); }
public void Verify_quartz_is_running() { // Arrange QuartzAdmin.web.Controllers.InstanceController controller = GetInstanceController(); QuartzAdmin.web.Models.InstanceModel instance = GetTestInstance(); controller.Repository.Save(instance); // Act ActionResult result = controller.Connect(instance.InstanceName); bool isConnected = false; if (result is ViewResult) { if (((ViewResult)result).ViewData.Model is QuartzAdmin.web.Models.InstanceViewModel) { isConnected = true; } } // Assert Assert.IsTrue(isConnected); }
private QuartzAdmin.web.Models.InstanceModel GetTestInstance() { QuartzAdmin.web.Models.InstanceModel instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = "MyTestInstance"; instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.scheduler.instanceName", PropertyValue = "SampleQuartzScheduler" }); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.threadPool.type", PropertyValue = "Quartz.Simpl.SimpleThreadPool, Quartz" }); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.scheduler.proxy", PropertyValue = "true" }); instance.InstanceProperties.Add(new QuartzAdmin.web.Models.InstancePropertyModel() { PropertyName = "quartz.scheduler.proxy.address", PropertyValue = "tcp://localhost:567/QuartzScheduler" }); return instance; }
public void ShouldInstancePropertiesBeEmpty() { Story instanceNameStory = new Story("Should instance name be null"); QuartzAdmin.web.Models.InstanceModel instance = null; instanceNameStory .AsA("System Admin") .IWant("to create a new quartz instance") .SoThat("I can administer it using this tool"); instanceNameStory .WithScenario("Create new instance with empty properties") .Given("The instance name is", "HelloWorld", delegate(string instanceName) { instance = new QuartzAdmin.web.Models.InstanceModel(); instance.InstanceName = instanceName; }) .When("the instance is validated") .Then("the validation should fail", delegate(){Assert.IsFalse(instance.IsValid());}); }