public IPathValue NewItem(IProviderContext context, string path, string itemTypeName, object newItemValue) { ITrigger trigger = null; var parameter = context.DynamicParameters as TriggerNewItemParameters; if (null != parameter) { if (parameter.Interval.HasValue) { trigger = new IntervalTrigger { Name = path, Interval = parameter.Interval.Value }; } else if (parameter.Manual) { trigger = new ManualTrigger { Name = path }; } } if (null == trigger) { trigger = new ImmediateTrigger { Name = path }; } _drive.Add(trigger); return(Resolve(context, path).First().GetNodeValue()); }
public void Setup() { Source = "IntervalTrigger"; mockDateTime = new DynamicMock(typeof(DateTimeProvider)); initialDateTimeNow = new DateTime(2002, 1, 2, 3, 0, 0, 0); mockDateTime.SetupResult("Now", this.initialDateTimeNow); trigger = new IntervalTrigger((DateTimeProvider)mockDateTime.MockInstance); }
public void Setup() { Source = "IntervalTrigger"; mockDateTime = new Mock <DateTimeProvider>(); initialDateTimeNow = new DateTime(2002, 1, 2, 3, 0, 0, 0); mockDateTime.SetupGet(provider => provider.Now).Returns(this.initialDateTimeNow); trigger = new IntervalTrigger((DateTimeProvider)mockDateTime.Object); }
public void ShouldDefaultPopulateFromReflector() { string xml = string.Format(@"<intervalTrigger />"); trigger = (IntervalTrigger)NetReflector.Read(xml); Assert.AreEqual(IntervalTrigger.DefaultIntervalSeconds, trigger.IntervalSeconds, "trigger.IntervalSeconds"); Assert.AreEqual(IntervalTrigger.DefaultIntervalSeconds, trigger.InitialIntervalSeconds, "trigger.InitialIntervalSeconds"); Assert.AreEqual(BuildCondition.IfModificationExists, trigger.BuildCondition, "trigger.BuildCondition"); Assert.AreEqual("IntervalTrigger", trigger.Name, "trigger.Name"); }
public void ShouldFullyPopulateFromReflector() { string xml = string.Format(@"<intervalTrigger name=""continuous"" seconds=""2"" initialSeconds=""1"" buildCondition=""ForceBuild"" />"); trigger = (IntervalTrigger)NetReflector.Read(xml); Assert.AreEqual(2, trigger.IntervalSeconds, "trigger.IntervalSeconds"); Assert.AreEqual(1, trigger.InitialIntervalSeconds, "trigger.InitialIntervalSeconds"); Assert.AreEqual(BuildCondition.ForceBuild, trigger.BuildCondition, "trigger.BuildCondition"); Assert.AreEqual("continuous", trigger.Name, "trigger.Name"); }
public void TestReadTriggers() { string xml = @"<triggers> <daily tag='restoreDB' timeOfDay='23:00'/> <weekly tag='backupDB' timeOfDay='01:30' weekDays='monday,friday'/> <hourly tag='delTempFiles' minutes='30'/> <interval tag='dumpLog' interval='00:05:00'/> <once tag='upgradeDB' dateTime='01/15/2007 23:00'/> <monthly tag='archiveDB' monthDay='29' timeOfDay='23:00'/> </triggers>"; IList <ITrigger> schedule = Trigger.ReadTriggers(xml); Assert.IsNotNull(schedule); Assert.AreEqual(6, schedule.Count); Assert.IsAssignableFrom(typeof(DailyTrigger), schedule[0]); Assert.IsAssignableFrom(typeof(WeeklyTrigger), schedule[1]); Assert.IsAssignableFrom(typeof(HourlyTrigger), schedule[2]); Assert.IsAssignableFrom(typeof(IntervalTrigger), schedule[3]); Assert.IsAssignableFrom(typeof(OnceTrigger), schedule[4]); Assert.IsAssignableFrom(typeof(MonthlyTrigger), schedule[5]); DailyTrigger daily = schedule[0] as DailyTrigger; Assert.AreEqual("restoreDB", daily.Tag); Assert.AreEqual(TimeSpan.FromHours(23), daily.TimeOfDay); WeeklyTrigger weekly = schedule[1] as WeeklyTrigger; Assert.AreEqual("backupDB", weekly.Tag); Assert.AreEqual(TimeSpan.FromMinutes(90), weekly.TimeOfDay); HourlyTrigger hourly = schedule[2] as HourlyTrigger; Assert.AreEqual("delTempFiles", hourly.Tag); Assert.AreEqual(30, hourly.Minutes); IntervalTrigger interval = schedule[3] as IntervalTrigger; Assert.AreEqual("dumpLog", interval.Tag); Assert.AreEqual(TimeSpan.FromMinutes(5), interval.Interval); OnceTrigger once = schedule[4] as OnceTrigger; Assert.AreEqual("upgradeDB", once.Tag); Assert.AreEqual(new DateTime(2007, 1, 15, 23, 0, 0), once.DateTime); MonthlyTrigger monthly = schedule[5] as MonthlyTrigger; Assert.AreEqual("archiveDB", monthly.Tag); Assert.AreEqual(29, monthly.MonthDay); Assert.AreEqual(TimeSpan.FromHours(23), monthly.TimeOfDay); }
public void RaisesTriggerOnSetInterval() { IntervalTrigger trigger = new IntervalTrigger(); trigger.Interval = TimeSpan.FromMilliseconds(100); int count = 0; trigger.Trigger += (s, a) => ++ count; Thread.Sleep(200); Assert.NotEqual(0, count); }
public PollingEndpointStub() { Trigger = new IntervalTrigger(TimeSpan.FromMilliseconds(500)); }