public void Test_CallExecuteOnScheduler_ChangePropertyAfterInitialized()
        {
            var scheduler = new MockScheduler();

            ReactivePropertyScheduler.SetDefault(scheduler);

            var commandArgument = new object();
            var mockCommand     = new Mock <ICommand>();

            mockCommand.Setup(x => x.Execute(It.Is <object>(y => y == commandArgument)))
            .Verifiable();
            mockCommand.Setup(x => x.CanExecute(It.IsAny <object>()))
            .Returns(true);

            var attachedTarget = new FrameworkElement();
            var target         = new EventToReactiveCommand
            {
                CallExecuteOnScheduler = false,
                Command = mockCommand.Object,
            };

            target.Attach(attachedTarget);

            target.CallExecuteOnScheduler = true;

            target.AsDynamic().Invoke(commandArgument);

            scheduler.CallHistory.Count.Is(1);
            mockCommand.VerifyAll();
        }
        public void ExpensesProperty()
        {
            ReactivePropertyScheduler.SetDefault(CurrentThreadScheduler.Instance);

            var navigationService = new Mock <INavigationService>();
            var referExpense      = new Mock <IReferExpense>();
            var expenses          = new ObservableCollection <Expense>();

            referExpense.Setup(m => m.Expenses).Returns(new ReadOnlyObservableCollection <Expense>(expenses));
            var actual = new ExpenseListPageViewModel(navigationService.Object, referExpense.Object);

            var expense = new Expense();

            expenses.Add(expense);
            Assert.Equal(1, actual.Expenses.Count);
            Assert.Equal(expense, actual.Expenses[0]);

            expenses.Clear();
            Assert.Equal(0, actual.Expenses.Count);

            actual.Destroy();

            expenses.Add(expense);
            Assert.Equal(0, actual.Expenses.Count);
        }
Exemplo n.º 3
0
    private void Application_Startup(object sender, StartupEventArgs e)
    {
        SetupLoggerConfig();
        DispatcherHelper.UIDispatcher = Dispatcher;
        ReactivePropertyScheduler.SetDefault(new ReactivePropertyWpfScheduler(Dispatcher));
        AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

        LogTo.Information("App Start");
        ChangeTheme();
    }
Exemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();

            ReactivePropertyScheduler.SetDefault(DispatcherScheduler.Current);

            var context = SynchronizationContext.Current;

            Task.Run(async() =>
            {
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await Task.Delay(100);
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await ReactivePropertyScheduler.Default;
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await ReactivePropertyScheduler.Default;
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await TaskPoolScheduler.Default;
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await TaskPoolScheduler.Default;
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await ReactivePropertyScheduler.Default;
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
                await ImmediateScheduler.Instance;
                Debug.WriteLine(Thread.CurrentThread.ManagedThreadId);
            });

            /*
             * Invoke(async () =>
             * {
             *  await Task.Delay(1000);
             *  Debug.WriteLine(1);
             *  throw new Exception("error");
             * })
             * .ContinueWith(task =>
             * {
             *  Debug.WriteLine(task);
             * });
             *
             * var random = new Random();
             * var randoms = Enumerable.Range(0, 100).Select(_ => random.Next(10, 100)).ToArray();
             *
             * Observable.Range(0, 100)
             *  .ObserveOn(TaskPoolScheduler.Default)
             *  .Select(async i =>
             *  {
             *      await Task.Delay(randoms[i]);
             *      return i;
             *  })
             *  .Concat()
             *  .ObserveOn(ReactivePropertyScheduler.Default)
             *  .Subscribe(i => Debug.WriteLine(i));*/
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();

            ReactivePropertyScheduler.SetDefault(DispatcherScheduler.Current);

            Items =
                Observable.Timer(TimeSpan.FromSeconds(2), DispatcherScheduler.Current)
                .Select(x =>
            {
                return(new[] { "Japan", "America" });
            })
                .ToRP(new[] { default(string) });

            Selected = Items.Select(xs => xs.FirstOrDefault()).ToRP();

            DataContext = this;
        }
Exemplo n.º 6
0
        private static void Main()
        {
            ReactivePropertyScheduler.SetDefault(ImmediateScheduler.Instance);

            CurrentHost = new Host();

            try
            {
                FileSystem = FileSystem.FromCommandLineArgs(new string[0], null);
                FileSystem.CreateFileSystem();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Translations.GetInterfaceString("errors_filesystem_invalid") + Environment.NewLine + Environment.NewLine + ex.Message, Translations.GetInterfaceString("program_title"), MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            Interface.LoadOptions();

            Renderer = new NewRenderer(CurrentHost, Interface.CurrentOptions, FileSystem);

            SoundApi = new SoundApi();
            SoundApi.Initialize(CurrentHost, SoundRange.Medium);

            string error;

            if (!CurrentHost.LoadPlugins(FileSystem, Interface.CurrentOptions, out error, null, Renderer))
            {
                SoundApi.Deinitialize();
                MessageBox.Show(error, @"OpenBVE", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            TrainManager = new Simulation.TrainManager.TrainManager(CurrentHost, null, null, FileSystem);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new FormEditor());

            CurrentHost.UnloadPlugins(out error);
            SoundApi.Deinitialize();

            Interface.SaveOptions();
        }
    public async Task Counts_NoFile()
    {
        ReactivePropertyScheduler.SetDefault(new ReactivePropertyWpfScheduler(Dispatcher.CurrentDispatcher));
        var model = CreateDefaultSettingModel();

        await model.LoadFileElements();

        var fileElementVMs = new FileElementsGridViewModel(model);

        //ステージ 置換前
        fileElementVMs.IsAnyFiles.Value
        .Should().BeTrue("ファイル読込後なので、ファイルはあるはず");

        var cViewFileElementVMs = (ListCollectionView)fileElementVMs.CViewFileElementVMs;

        cViewFileElementVMs.IsEmpty
        .Should().BeFalse("ファイル読込後なので、ファイルはあるはず");
        cViewFileElementVMs.Count
        .Should().Be(6, "ファイル読込後なので、ファイルはあるはず");

        fileElementVMs.CountReplaced.Value
        .Should().Be(0, "置換前はまだ0のはず");

        fileElementVMs.CountConflicted.Value
        .Should().Be(0, "置換前はまだ0のはず");

        //ステージ なにも置換しない置換後
        await model.Replace();

        await model.WaitIdleUI().Timeout(3000);

        fileElementVMs.CountReplaced.Value
        .Should().Be(0, "置換する設定がないので、0のはず");
        fileElementVMs.CountConflicted.Value
        .Should().Be(0, "置換する設定がないので、0のはず");

        fileElementVMs.IsReplacedAny.Value
        .Should().BeFalse("置換する設定がないので、0のはず");
        fileElementVMs.IsNotConflictedAny.Value
        .Should().BeTrue("置換する設定がないので、0のはず");
    }
        public void ReportProperty()
        {
            ReactivePropertyScheduler.SetDefault(CurrentThreadScheduler.Instance);
            var navigationService = new Mock <INavigationService>();
            var referReport       = new Mock <IReferReport>();
            var reports           = new ObservableCollection <Report>();
            var readOnlyReports   = new ReadOnlyObservableCollection <Report>(reports);

            referReport
            .Setup(m => m.Reports)
            .Returns(readOnlyReports);

            var actual = new ReportListPageViewModel(navigationService.Object, referReport.Object);

            Assert.Equal(0, actual.Reports.Count);

            var report = new Report();

            reports.Add(report);

            Assert.Equal(1, actual.Reports.Count);
            Assert.Equal(report, actual.Reports[0]);
        }
Exemplo n.º 9
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     // [ReactiveProperty 7.10.0 をリリースしました](https://zenn.dev/okazuki/articles/62a6c6c9d1a12baccc93)
     // WPFに最適化されたScheduler (デフォルトで問題が起きる Windowの ctor や Loadedイベント時の Validation を改善)
     ReactivePropertyScheduler.SetDefault(new ReactivePropertyWpfScheduler(Dispatcher));
 }
Exemplo n.º 10
0
 /// <inheritdoc />
 protected override void OnStartup(StartupEventArgs e)
 {
     base.OnStartup(e);
     ReactivePropertyScheduler.SetDefault(ImmediateScheduler.Instance);
 }
Exemplo n.º 11
0
 protected override void Initialize()
 {
     ReactivePropertyScheduler.SetDefault(new ReactivePropertyWpfScheduler(Dispatcher));
     base.Initialize();
 }
Exemplo n.º 12
0
 public static void Initialize(TestContext context)
 {
     ServicePointManager.Expect100Continue = false;
     ReactivePropertyScheduler.SetDefault(Scheduler.CurrentThread);
 }
Exemplo n.º 13
0
 static MainWindow()
 {
     ReactivePropertyScheduler.SetDefault(UIDispatcherScheduler.Default);
 }
Exemplo n.º 14
0
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     ReactivePropertyScheduler.SetDefault(new ReactivePropertyWpfScheduler(Dispatcher));
 }
Exemplo n.º 15
0
 void IDisposable.Dispose()
 {
     ReactivePropertyScheduler.SetDefault(DefaultScheduler.Instance);
 }
Exemplo n.º 16
0
 public LoginPageViewModelTest()
 {
     ReactivePropertyScheduler.SetDefault(CurrentThreadScheduler.Instance);
 }