Esempio n. 1
0
        public async Task SingleConfiguration()
        {
            // Prepare the model
            var debugConfigProps = new TestProjectProperties(false, "script.R", "-debug");

            // Prepare the view model
            var vm = new RunPageViewModel(new IRProjectProperties[] { debugConfigProps });

            // Initialize the view model from the model
            await vm.Initialize();

            // Verify view model is initialized correctly
            vm.ResetReplOnRun.Should().Be(false);
            vm.StartupFile.Should().Be("script.R");
            vm.CommandLineArgs.Should().Be("-debug");

            bool dirty = false;

            vm.PropertyChanged += (object sender, PropertyChangedEventArgs e) => {
                if (!vm.IgnoreEvents)
                {
                    dirty = true;
                }
            };

            // Simulate a view model change from UI
            vm.ResetReplOnRun = true;
            dirty.Should().Be(true);

            // Save the view model into the model
            await vm.Save();

            // Verify model has been updated
            debugConfigProps.ShouldBeEquivalentTo(new TestProjectProperties(true, "script.R", "-debug"));
        }
Esempio n. 2
0
        public async Task MultiConfigurationsChangeConflictingStartupFile()
        {
            // Prepare the model
            var debugConfigProps   = new TestProjectProperties(false, "debug.R", "-option");
            var releaseConfigProps = new TestProjectProperties(true, "release.R", "-option");

            // Prepare the view model
            var vm = new RunPageViewModel(new IRProjectProperties[] { debugConfigProps, releaseConfigProps });

            // Initialize the view model from the model
            await vm.Initialize();

            // Verify view model is initialized correctly
            vm.ResetReplOnRun.Should().Be(PropertyPageViewModel.DifferentBoolOptions);
            vm.StartupFile.Should().Be(PropertyPageViewModel.DifferentStringOptions);
            vm.CommandLineArgs.Should().Be("-option");

            bool dirty = false;

            vm.PropertyChanged += (object sender, PropertyChangedEventArgs e) => {
                if (!vm.IgnoreEvents)
                {
                    dirty = true;
                }
            };

            // Simulate a view model change from UI
            vm.StartupFile = "common.R";
            dirty.Should().Be(true);

            // Save the view model into the model
            await vm.Save();

            // Verify model has been updated
            debugConfigProps.ShouldBeEquivalentTo(new TestProjectProperties(false, "common.R", "-option"));
            releaseConfigProps.ShouldBeEquivalentTo(new TestProjectProperties(true, "common.R", "-option"));
        }