Ejemplo n.º 1
0
        public void AsyncCommandSmokeTest()
        {
            var inflight_results = new List<int>();
            var fixture = new ReactiveAsyncCommand(null, 1, Scheduler.Immediate);

            var async_data = fixture
                .ObserveOn(Scheduler.NewThread)
                .Delay(new TimeSpan(0, 0, 5))
                .Select(_ => 5)
                .Do(_ => fixture.AsyncCompletedNotification.OnNext(new Unit()));

            fixture.ItemsInflight.Subscribe(x => inflight_results.Add(x));

            async_data.Subscribe();

            Assert.IsTrue(fixture.CanExecute(null));

            fixture.Execute(null);
            Assert.IsFalse(fixture.CanExecute(null));

            Thread.Sleep(5500);
            Assert.IsTrue(fixture.CanExecute(null));

            new[] {0,1,0}.Zip(inflight_results, (expected, actual) => new {expected, actual})
                         .Run(x => Assert.AreEqual(x.expected, x.actual));
        }