예제 #1
0
 public void CanSearch()
 {
     new TestScheduler().With(
         async scheduler =>
     {
         instance   = new DataSelectViewModel(dataHandler.Object, factory.Object, openFolder.Object);
         var result = await instance.Perform.CanExecute;
         Assert.IsFalse(result);
         instance.Select.Path = ".";
         scheduler.AdvanceByMs(500);
         result = await instance.Perform.CanExecute;
         Assert.IsTrue(result);
     });
 }
예제 #2
0
        public void Search()
        {
            new TestScheduler().With(
                async scheduler =>
            {
                instance             = new DataSelectViewModel(dataHandler.Object, factory.Object, openFolder.Object);
                instance.Select.Path = ".";
                fileManager.Setup(item => item.LoadAll(It.IsAny <DirectoryInfo>()))
                .Returns(Task.FromResult(set));
                DocumentSet result = null;
                instance.Perform.Subscribe(
                    results =>
                {
                    result = results;
                });

                scheduler.AdvanceByMs(500);
                await instance.Perform.Execute();
                scheduler.AdvanceByMs(500);
                Assert.AreEqual(set, result);
            });
        }
예제 #3
0
 public void CanCancel()
 {
     new TestScheduler().With(
         async scheduler =>
     {
         instance             = new DataSelectViewModel(dataHandler.Object, factory.Object, openFolder.Object);
         var result           = await instance.Cancel.CanExecute;
         instance.Select.Path = ".";
         Assert.IsFalse(result);
         fileManager.Setup(item => item.LoadAll(It.IsAny <DirectoryInfo>()))
         .Returns(async() => await(Observable.Start(() => set, scheduler).Delay(TimeSpan.FromSeconds(1.0))));
         scheduler.AdvanceByMs(200);
         await instance.Perform.Execute();
         scheduler.AdvanceByMs(200);
         Assert.IsFalse(token.IsCancellationRequested);
         result = await instance.Cancel.CanExecute;
         Assert.IsTrue(result);
         await instance.Cancel.Execute();
         scheduler.AdvanceByMs(10);
         Assert.IsTrue(token.IsCancellationRequested);
     });
 }