Inheritance: TaskScheduler, IScheduler
Exemplo n.º 1
0
            public void ReturnsTheCorrectNextScheduleWhenRunComplete()
            {
                var startDate = DateTime.UtcNow.AddMilliseconds(-7);
                var dates = new Queue<DateTime>(new[]
                {
                    startDate,
                    startDate.AddSeconds(7),
                    startDate.AddSeconds(10),
                    startDate.AddSeconds(14),
                    startDate.AddSeconds(17),
                });

                var jobs = new[] { new WaitJob(10), new WaitJob(7), new WaitJob(17) };
                var scheduler = new Scheduler(jobs, dates.Dequeue);

                var firstSchedule = scheduler.Next();
                firstSchedule.Job.Execute();
                firstSchedule.SetRunComplete();
                var secondSchedule = scheduler.Next();
                secondSchedule.SetRunComplete();
                var thirdSchedule = scheduler.Next();

                thirdSchedule.SetRunComplete();
                var fourthSchedule = scheduler.Next();
                fourthSchedule.SetRunComplete();

                Assert.Equal(7, ((WaitJob)firstSchedule.Job).Id);
                Assert.Equal(10, ((WaitJob)secondSchedule.Job).Id);
                Assert.Equal(7, ((WaitJob)thirdSchedule.Job).Id);
                Assert.Equal(17, ((WaitJob)fourthSchedule.Job).Id);
            }
Exemplo n.º 2
0
            public void ReturnsTheScheduleWithTheLowestRunTime()
            {
                var jobOne = new Mock<IJob>();
                jobOne.Setup(j => j.Interval).Returns(TimeSpan.FromSeconds(10));
                var jobTwo = new Mock<IJob>();
                jobTwo.Setup(j => j.Interval).Returns(TimeSpan.FromSeconds(7));
                var jobThree = new Mock<IJob>();
                jobThree.Setup(j => j.Interval).Returns(TimeSpan.FromSeconds(27));
                var jobs = new[] { jobOne.Object, jobTwo.Object, jobThree.Object };
                var scheduler = new Scheduler(jobs);

                var schedule = scheduler.Next();

                Assert.Equal(jobTwo.Object, schedule.Job);
            }
        public void Given_scheduler_with_some_work()
        {
            var ctx = new TestWorkContext();
            _scheduler = new Scheduler(ctx);

            _scheduler.Schedule("Foo1", () => { _foo1WorkDone = true; }, TimeSpan.FromMinutes(10));
            _scheduler.Schedule("Foo2", () => { _foo2WorkDone = true; }, TimeSpan.FromMinutes(10));

            // Lest ensure that all workitems
            // are applicable for schedule
            ctx.MoveToTommorrow();

            _scheduler.Start();

            Wait.Unitl(() => _scheduler.Stats.RunningJobs + _scheduler.Stats.ScheduledJobs == 0);
        }
Exemplo n.º 4
0
        public WMCDataSource()
        {
            SHA256 sha = SHA256Managed.Create();

            // This is the magic way to get R/W access to the database.  Cannot be guaranteed to work in future versions of windows
            string providerName = Encoding.Unicode.GetString(Convert.FromBase64String("QQBuAG8AbgB5AG0AbwB1AHMAIQBVAHMAZQByAA=="));

            string epgClientID = ObjectStore.GetClientId(true);
            byte[] epgBytes = Encoding.Unicode.GetBytes(epgClientID);
            byte[] epgHashed = sha.ComputeHash(epgBytes);
            string providerPassword = Convert.ToBase64String(epgHashed);
            os = ObjectStore.Open(providerName, providerPassword);

            recScheduler = new Scheduler(os, ScheduleConflictSource.AutomaticUpdate);

            channels = new Lazy<List<Channel>>(GetAllChannels);
        }
        protected TestContainerDiscoverer(
            IServiceProvider serviceProvider,
            ITestsService testsService,
            TestSettingsProvider testSettingsProvider,
            ITestLogger logger
            )
        {
            Logger = logger;
            try
            {
                TestSettingsProvider = testSettingsProvider;
                TestAdapterInfo = CreateTestAdapterInfo();

                Containers = new TestContainerList(this);

                ServiceProvider = serviceProvider;
                _testsService = testsService;

                SolutionListener = new SolutionListener(serviceProvider);
                SolutionListener.SolutionLoaded += OnSolutionLoaded;
                SolutionListener.SolutionUnloaded += OnSolutionUnloaded;
                SolutionListener.ProjectChanged += OnSolutionProjectChanged;
                SolutionListener.StartListening();

                ProjectListener = new ProjectListener(serviceProvider, Logger);
                ProjectListener.FileAdded += (source, e) => OnProjectFileAdded(e.Project, e.File);
                ProjectListener.FileRemoved += (source, e) => OnProjectFileRemoved(e.Project, e.File);
                ProjectListener.FileRenamed += (source, e) => OnProjectFileRenamed(e.Project, e.OldFile, e.NewFile);
                ProjectListener.StartListening();

                RunScheduler = new Scheduler(250, RunTestsInternal);
                RefreshTestContainersScheduler = new Scheduler<string>(250, RefreshTestContainersInternal);

                Logger.Debug("TestContainerDiscoverer created");
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw;
            }
        }
Exemplo n.º 6
0
		public void CustomScheduler ()
		{
			// some test runners (e.g. Touch.Unit) will execute this on the main thread and that would lock them
			if (!Thread.CurrentThread.IsBackground)
				Assert.Ignore ("Current thread is not running in the background.");

			var a = new Scheduler ("a");
			var b = new Scheduler ("b");

			var t = TestCS (a, b);
			Assert.IsTrue (t.Wait (3000), "#0");
			Assert.AreEqual (0, t.Result, "#1");
			Assert.AreEqual (0, b.InlineCalls, "#2b");
			Assert.IsTrue (a.QueueCalls == 1 || a.QueueCalls == 2, "#3a");
			Assert.AreEqual (1, b.QueueCalls, "#3b");
		}
Exemplo n.º 7
0
 public void ChangementResultat(object sender, Scheduler.EventArgsResultat e)
 {
     LabelCouverture.Text = e.Couverture;
 }
 public void TestInitialize() {
     _scheduler = new Scheduler<AbstractViewModel>();
     _scheduler.Interval = 1000;
 }
 public RemoteMetricsContext(Scheduler scheduler, Uri remoteUri, TimeSpan updateInterval, Func<string, JsonMetricsContext> deserializer)
 {
     this.scheduler = scheduler;
     this.scheduler.Start(updateInterval, c => UpdateMetrics(remoteUri, deserializer, c));
 }