public void Configure(IScheduler scheduler, Stream source)
        {
            using (var tr = new StreamReader(source))
            {
                var document = XDocument.Load(tr);

                foreach (var addDef in XmlJobParser.Parse(document))
                {
                    addDef(scheduler);
                }
            }
        }
Example #2
0
        public void ForValidXmlShouldAddJob()
        {
            // arrange
            var xmlString = string.Format("<Job JobType=\"{0}\" Interval=\"00:00:01\"/>", typeof(DummyJob).AssemblyQualifiedName);
            var xml       = XElement.Parse(xmlString);

            // act
            XmlJobParser.Parse(xml)(this.Scheduler.Object);

            // assert
            this.Scheduler.Verify(x => x.AddJob <DummyJob>(It.Is <JobSetup>(y => (y.WaitSource as IntervalWaitSource).Interval == TimeSpan.FromSeconds(1))), Times.Once);
        }
Example #3
0
        public void ForCoupleJobDefinitionsShouldConfigureCoupleJobs()
        {
            // arrange
            var xmlString = string.Format("<Jobs><Job JobType=\"{0}\" Interval=\"00:00:01\"/><Job JobType=\"{0}\" Interval=\"12:00:01\"/></Jobs>", typeof(DummyJob).AssemblyQualifiedName);
            var xml       = XDocument.Parse(xmlString);

            // act
            foreach (var f in XmlJobParser.Parse(xml))
            {
                f(this.Scheduler.Object);
            }

            // assert
            this.Scheduler.Verify(x => x.AddJob <DummyJob>(It.Is <JobSetup>(y => (y.WaitSource as IntervalWaitSource).Interval == TimeSpan.FromSeconds(1))), Times.Once);
            this.Scheduler.Verify(x => x.AddJob <DummyJob>(It.Is <JobSetup>(y => (y.WaitSource as IntervalWaitSource).Interval == TimeSpan.Parse("12:00:01"))), Times.Once);
        }