当前位置: 首页>>代码示例>>C#>>正文


C# TestScheduler.AdvanceTo方法代码示例

本文整理汇总了C#中TestScheduler.AdvanceTo方法的典型用法代码示例。如果您正苦于以下问题:C# TestScheduler.AdvanceTo方法的具体用法?C# TestScheduler.AdvanceTo怎么用?C# TestScheduler.AdvanceTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestScheduler的用法示例。


在下文中一共展示了TestScheduler.AdvanceTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: When_Path_Has_Null_Intermediary_Node_Then_Propagates_ProvertyValueChanged_With_HasValue_False

        public void When_Path_Has_Null_Intermediary_Node_Then_Propagates_ProvertyValueChanged_With_HasValue_False()
        {
            // Arrange
            var childOne = new TestObservableObject {Age = 5};
            var childTwo = new TestObservableObject {Age = 17};
            var obj = new TestObservableObject {ObservableChild = childOne};
            var scheduler = new TestScheduler();

            var observer = scheduler.CreateObserver<IPropertyValueChanged<int>>();
            var expected = new[]
            {
                OnNext(000, PropertyValueChanged.CreateWithValue(childOne, "Age", childOne.Age)),
                OnNext(000, PropertyValueChanged.CreateWithValue(childOne, "Age", 20)),
                OnNext(100, PropertyValueChanged.CreateWithoutValue<TestObservableObject, int>(null, "Age")),
                OnNext(300, PropertyValueChanged.CreateWithValue(childTwo, "Age", childTwo.Age)),
            };

            var sut = obj.When(x => x.ObservableChild.Age);

            // Act
            sut.Subscribe(observer);
            obj.ObservableChild.Age = 20;
            scheduler.AdvanceTo(100);
            obj.ObservableChild = null;
            scheduler.AdvanceTo(300);
            obj.ObservableChild = childTwo;

            // Assert
            Assert.AreEqual(expected, observer.Messages);
        }
开发者ID:jonclare,项目名称:KodeKandy,代码行数:30,代码来源:Given_When_And_Final_Node_INotifyPropertyChanged.cs

示例2: When_Path_Has_Null_Intermediary_Node_Then_Skips_When_Invalid_Path

        public void When_Path_Has_Null_Intermediary_Node_Then_Skips_When_Invalid_Path()
        {
            // Arrange
            var childOne = new TestObservableObject {Age = 5};
            var childTwo = new TestObservableObject {Age = 17};
            var obj = new TestObservableObject {ObservableChild = childOne};
            var scheduler = new TestScheduler();

            var observer = scheduler.CreateObserver<int>();
            var expected = new[]
            {
                OnNext(000, childOne.Age),
                OnNext(000, 20),
                OnNext(300, childTwo.Age),
            };

            var sut = obj.WhenValue(x => x.ObservableChild.Age);

            // Act
            sut.Subscribe(observer);
            obj.ObservableChild.Age = 20;
            scheduler.AdvanceTo(100);
            obj.ObservableChild = null;
            scheduler.AdvanceTo(300);
            obj.ObservableChild = childTwo;

            // Assert
            Assert.AreEqual(expected, observer.Messages);
        }
开发者ID:jonclare,项目名称:KodeKandy,代码行数:29,代码来源:Given_WhenValue_And_Final_Node_INotifyPropertyChanged.cs

示例3: When_Subscribed_Then_OnNext_Changes

        public void When_Subscribed_Then_OnNext_Changes()
        {
            // Arrange
            var obj = new TestObservableObject {ObservableChild = new TestObservableObject {Age = 3}};
            var replacementChild = new TestObservableObject {Age = 5};
            var scheduler = new TestScheduler();
            var observer = scheduler.CreateObserver<TestObservableObject>();
            var expected = new[]
            {
                OnNext(000, obj.ObservableChild),
                OnNext(010, replacementChild),
                OnNext(010, replacementChild),
                OnNext(020, replacementChild),
            };

            var sut = obj.WhenAny(x => x.ObservableChild).ForProperty<TestObservableObject>("Age", "Name");

            // Act
            sut.Subscribe(observer);
            scheduler.AdvanceTo(10);
            obj.ObservableChild = replacementChild;
            obj.ObservableChild.Age = 17;
            scheduler.AdvanceTo(20);
            obj.ObservableChild.Name = "Billy";

            // Assert
            Assert.AreEqual(expected, observer.Messages);
        }
开发者ID:jonclare,项目名称:KodeKandy,代码行数:28,代码来源:When_ForProperty.cs

示例4: ShouldReturnValueAfterTime

        public void ShouldReturnValueAfterTime()
        {
            var expected = "FDA";
            var scheduler = new TestScheduler();
            var obs = Typing(expected, 5, scheduler);
            string result = null;
            obs.Subscribe(x => result = x);
            scheduler.AdvanceTo(TimeSpan.FromSeconds(3).Ticks);

            Assert.Equal(null, result);

            scheduler.AdvanceTo(TimeSpan.FromSeconds(6).Ticks);

            Assert.Equal(expected, result);
        }
开发者ID:jiravanet,项目名称:Prezentace-Rx,代码行数:15,代码来源:ObservableTest.cs

示例5: TimerTestStart2

        public void TimerTestStart2()
        {
            var testScheduler = new TestScheduler();
            var recorder = testScheduler.CreateObserver<long>();

            var timer = new ReactiveTimer(TimeSpan.FromSeconds(1), testScheduler);
            timer.Subscribe(recorder);

            timer.Start();

            testScheduler.AdvanceTo(TimeSpan.FromSeconds(3).Ticks + 1);

            recorder.Messages.Is(
                OnNext(TimeSpan.FromSeconds(0).Ticks + 1, 0L),
                OnNext(TimeSpan.FromSeconds(1).Ticks + 1, 1L),
                OnNext(TimeSpan.FromSeconds(2).Ticks + 1, 2L),
                OnNext(TimeSpan.FromSeconds(3).Ticks + 1, 3L));
            
            timer.Stop();
            recorder.Messages.Clear();

            testScheduler.AdvanceBy(TimeSpan.FromSeconds(5).Ticks);

            recorder.Messages.Count.Is(0);
        }
开发者ID:ailen0ada,项目名称:ReactiveProperty,代码行数:25,代码来源:ReactiveTimerTest.cs

示例6: TimeSource101

        public void TimeSource101()
        {
            TestScheduler scheduler = new TestScheduler();
            var xs = scheduler.CreateHotObservable(s_testData);

            var timeSource = new TimeSource<long>(xs, x => new DateTimeOffset(x, TimeSpan.Zero));
            timeSource.StartTime = new DateTimeOffset(101, TimeSpan.Zero);

            var counts = from window in timeSource.Window(TimeSpan.FromTicks(5), timeSource.Scheduler)
                         from Count in window.Count()
                         select Count;

            var list = new List<Timestamped<int>>();
            counts
                .Timestamp(timeSource.Scheduler)
                .Subscribe(ts => list.Add(ts));

            timeSource.Connect();
            scheduler.AdvanceTo(120);

            Assert.AreEqual(3, list.Count);
            list.AssertEqual(
                Result(106, 2),
                Result(111, 3),
                Result(115, 1));
        }
开发者ID:theperm,项目名称:RxM4A,代码行数:26,代码来源:TimeSourceTest.cs

示例7: ScheduleTask_Should_Call_Sample_On_Scheduler

        public void ScheduleTask_Should_Call_Sample_On_Scheduler()
        {
            // Arrange
            const int count = 5;

            var scheduler = new TestScheduler();
            var settings = new TaskSchedulerSettings
            {
                RequestDelay = TimeSpan.FromMilliseconds(250)

            };
            ITaskScheduler taskScheduler = new DelayTaskScheduler(settings, scheduler);

            // Act
            var tasks = Enumerable.Range(0, count + 1)
                                  .Select(i => Task.Run(() => Task.FromResult(i)))
                                  .Select(t => taskScheduler.ScheduleTask(() => t))
                                  .ToArray();

            scheduler.AdvanceTo(settings.RequestDelay.Ticks * count);

            // Assert
            tasks.Count(t => t.IsCompleted).Should().Be(count);
            taskScheduler.Dispose();
        }
开发者ID:abatishchev,项目名称:ab,代码行数:25,代码来源:DelayTaskSchedulerTest.cs

示例8: SelectDisposableShouldWork

        public void SelectDisposableShouldWork()
        {
            var scheduler = new TestScheduler();
            var disposables = new List<BooleanDisposable>();
            var list = new CompositeDisposable();
            scheduler.CreateColdObservable(
                new Recorded<Notification<long>>(100, Notification.CreateOnNext(0L)),
                new Recorded<Notification<long>>(200, Notification.CreateOnNext(1L)),
                new Recorded<Notification<long>>(300, Notification.CreateOnNext(2L)),
                new Recorded<Notification<long>>(400, Notification.CreateOnNext(3L)),
                new Recorded<Notification<long>>(400, Notification.CreateOnCompleted<long>())
            )
            .SelectDisposable(list, i => {
                var d = new BooleanDisposable();
                disposables.Add(d);
                return d;
            }, (i, _) => i)
            .Subscribe()
            .DisposeWith(list);

            scheduler.AdvanceTo(300);

            disposables.Count.Should().Be(3);

            disposables.Select(d => d.IsDisposed).Should().NotContain(true);

            list.Dispose();

            disposables.Select(d => d.IsDisposed).Should().NotContain(false);

        }
开发者ID:Weingartner,项目名称:SolidworksAddinFramework,代码行数:31,代码来源:DisposableExtensionsSpec.cs

示例9: SetUp

 public void SetUp()
 {
     testScheduler = new TestScheduler();
     testScheduler.AdvanceTo(DateTimeOffset.UtcNow.Ticks);
     nodes = TestNode.CreateCluster(scheduler: testScheduler);
     nodes.Start();
     leader = nodes.WaitForLeader(testScheduler).Result;
 }
开发者ID:jonsequitur,项目名称:JollyRaft,代码行数:8,代码来源:Given_a_leader_that_has_been_elected.cs

示例10: Clock

 public void Clock()
 {
     var scheduler = new TestScheduler ();
     Assert.AreEqual (0, scheduler.Clock, "#1"); // default
     scheduler.AdvanceBy (TimeSpan.FromDays (1).Ticks);
     Assert.AreEqual (TimeSpan.FromDays (1).Ticks, scheduler.Clock, "#2");
     var dt = new DateTimeOffset (2012, 1, 1, 0, 0, 0, TimeSpan.Zero);
     scheduler.AdvanceTo (dt.Ticks);
     Assert.AreEqual (dt, new DateTimeOffset (scheduler.Clock, TimeSpan.Zero), "#3");
 }
开发者ID:jorik041,项目名称:mono-reactive,代码行数:10,代码来源:TestSchedulerTest.cs

示例11: elections_are_ran_shortly_after_node_startup

        public void elections_are_ran_shortly_after_node_startup()
        {
            var testScheduler = new TestScheduler();
            testScheduler.AdvanceTo(DateTimeOffset.UtcNow.Ticks);
            var nodes = TestNode.CreateCluster(scheduler: testScheduler);
            nodes.Start();

            testScheduler.AdvanceBy(TestNode.ElectionTimeout.Ticks);
            nodes.Should().ContainSingle(n => n.State == State.Leader || n.State == State.Candidate);
        }
开发者ID:jonsequitur,项目名称:JollyRaft,代码行数:10,代码来源:ElectionTests.cs

示例12: SimpleDelay

        public void SimpleDelay()
        {
            var receivedSignals = new List<int>();
            var subject = new Subject<int>();
            var scheduler = new TestScheduler();
            subject.UniqueThrottle(TimeSpan.FromTicks(25), scheduler).Subscribe(x => receivedSignals.Add(x));


            subject.OnNext(1);
            receivedSignals.Count.Should().Be(0);

            scheduler.AdvanceTo(24);
            receivedSignals.Count.Should().Be(0);

            scheduler.AdvanceTo(25);
            receivedSignals.Count.Should().Be(1);

            scheduler.AdvanceTo(100);
            receivedSignals.Count.Should().Be(1);
        }
开发者ID:rog1039,项目名称:Rogero.RxExtensions,代码行数:20,代码来源:KeyedBufferTests.cs

示例13: SetUp

        public void SetUp()
        {
            testScheduler = new TestScheduler();
            testScheduler.AdvanceTo(DateTimeOffset.UtcNow.Ticks);
            nodes = TestNode.CreateCluster(scheduler: testScheduler);
            nodes.Start();
            leader = nodes.WaitForLeader(testScheduler).Result;

            darkNode = nodes.First(n => n != leader) as TestNode;
            darkNode.SleepOnAppendEntries = true;
        }
开发者ID:jonsequitur,项目名称:JollyRaft,代码行数:11,代码来源:Given_a_cluster_with_a_leader_and_one_node_that_has_gone_dark.cs

示例14: AsyncGetTest

        public void AsyncGetTest()
        {
            var input = new[] { 1, 1, 1, 1, 1 };
            var sched = new TestScheduler();

            var delay = TimeSpan.FromSeconds(1.0);
            var fixture = new ObservableAsyncMRUCache<int, int>(x => Observable.Return(x*5).Delay(delay, sched), 5, 2, null, sched);

            int result = 0;
            input.ToObservable(sched).SelectMany<int, int>(x => (IObservable<int>)fixture.AsyncGet(x)).Subscribe(x => result += x);

            sched.AdvanceTo(sched.FromTimeSpan(TimeSpan.FromMilliseconds(500)));
            Assert.Equal(0, result);

            sched.AdvanceTo(sched.FromTimeSpan(TimeSpan.FromMilliseconds(1200)));
            Assert.Equal(25, result);

            sched.Start();
            Assert.Equal(25, result);
        }
开发者ID:bradphelan,项目名称:ReactiveUI,代码行数:20,代码来源:ObservableAsyncMRUCacheTest.cs

示例15: SendNotification_1EventAfter0SecondThen1After3Minutes_Expect1NotificationSentAfter5Minutes

        public void SendNotification_1EventAfter0SecondThen1After3Minutes_Expect1NotificationSentAfter5Minutes()
        {
            //Arrange
            var eventEmitter = new MvvmLightMessenger();

            var robot = Substitute.For<IRobot>();
            robot.EventEmitter.Returns(eventEmitter);

            var scheduler = new TestScheduler();
            var jiraAggregator = new JiraAggregatorSut(robot, scheduler);

            var user = new User { displayName = "Laurent Kempé", name = "laurent" };

            var addCommentEvent1 = new JiraModel
            {
                issue = new Issue { key = "LK-10", fields = new Fields { reporter = user, assignee = user } },
                webhookEvent = "jira:issue_created",
                comment = new CommentDetails(),
                user = user
            };

            var addCommentEvent2 = new JiraModel
            {
                issue = new Issue { key = "LK-10", fields = new Fields { reporter = user, assignee = user } },
                webhookEvent = "jira:issue_updated",
                comment = new CommentDetails(),
                user = user
            };

            //Act
            scheduler.Schedule(TimeSpan.FromSeconds(0), () => eventEmitter.Emit("JiraEvent", addCommentEvent1));
            scheduler.Schedule(TimeSpan.FromSeconds(120), () => eventEmitter.Emit("JiraEvent", addCommentEvent2));

            scheduler.AdvanceTo(TimeSpan.FromSeconds(181).Ticks);
            robot.Received(0).SendNotification("", "", "Message", true);

            scheduler.AdvanceTo(TimeSpan.FromMinutes(5).Ticks);

            //Assert
            robot.Received(1).SendNotification(Arg.Any<string>(), Arg.Any<string>(), Arg.Any<string>(), true);
        }
开发者ID:martinskuta,项目名称:Nubot,代码行数:41,代码来源:JiraAggregatorTests.cs


注:本文中的TestScheduler.AdvanceTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。