Example #1
0
 public void LoadLoadsCode()
 {
     SetupSut();
     _mockExpressionEvaluator.Setup(mee => mee.GetExpression()).Returns(new Accumulator(@"c:\myfile.bas"));
     _sut.Execute(_mockTokeniser.Object);
     _mockProgramRepository.Verify(mpr => mpr.SetProgramLine(_line10), Times.Once);
     _mockProgramRepository.Verify(mpr => mpr.SetProgramLine(_line20), Times.Once);
     _mockProgramRepository.Verify(mpr => mpr.SetProgramLine(_line30), Times.Once);
 }
 private void Load_Released(object sender, PointerRoutedEventArgs e)
 {
     if (Load != null)
     {
         Load.Execute(null);
     }
 }
Example #3
0
        public void Execute_OfSave_StoresFilename()
        {
            var programRepository = MakeProgramRepository();
            var rte  = MakeRunTimeEnvironment(programRepository);
            var load = new Load("filename");

            load.Execute(rte);

            Assert.AreEqual("filename", rte.Variables.LastUsedProgramName);
        }
Example #4
0
        public void Execute_OfLoad_UsesFilename()
        {
            var programRepository = MakeProgramRepository();
            var rte  = MakeRunTimeEnvironment(programRepository);
            var load = new Load("filename");

            load.Execute(rte);

            Assert.AreEqual("filename", programRepository.LastFileName);
        }
Example #5
0
        public void Execute_OfLoad_LoadsLines()
        {
            var programRepository = MakeProgramRepository();
            var rte  = MakeRunTimeEnvironment(programRepository);
            var load = new Load("filename");

            load.Execute(rte);
            var expected = programRepository.Lines.ToList();
            var actual   = rte.Lines;

            CollectionAssert.AreEqual(expected, actual);
        }
Example #6
0
        public MainWindowViewModel()
        {
            Load = ReactiveCommand.CreateFromTask(LoadImpl);
            Load.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            AddTask = ReactiveCommand.CreateFromTask(AddTaskImpl);
            AddTask.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            AddTaskType = ReactiveCommand.CreateFromTask(AddTaskTypeImpl);
            AddTaskType.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            AddTaskStatus = ReactiveCommand.CreateFromTask(AddTaskStatusImpl);
            AddTaskStatus.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            AddCalendar = ReactiveCommand.CreateFromTask(AddCalendarImpl);
            AddCalendar.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            DeleteCalendar = ReactiveCommand.CreateFromTask <Calendar>(DeleteCalendarImpl);
            DeleteCalendar.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            RefreshShowedTasks = ReactiveCommand.CreateFromTask(RefreshShowedTasksImpl);
            RefreshShowedTasks.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            SetValidDates = ReactiveCommand.Create <CurrentView>(SetValidDatesImpl);
            SetValidDates.ThrownExceptions.Subscribe(ex => { Debug.WriteLine(ex); });

            this.WhenAnyValue(
                x => x.ViewStartDate,
                x => x.ViewEndDate,
                x => x.SelectedTaskStatus,
                x => x.SelectedTaskType,
                x => x.SelectedCalendar)
            .Throttle(new TimeSpan(0, 0, 0, 0, 30))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Select(x => Unit.Default)
            .InvokeCommand(RefreshShowedTasks);

            this.WhenAnyObservable(x => x.RefreshShowedTasks.IsExecuting)
            .ToPropertyEx(this, x => x.IsLoading);

            // Test load
            Load.Execute();
        }
Example #7
0
        public FeedViewModel(
            Func <Category, FeedGroupViewModel> factory,
            INavigationService navigationService,
            ICategoryManager categoryManager)
        {
            _navigationService = navigationService;
            _categoryManager   = categoryManager;
            _factory           = factory;

            Items  = new ReactiveList <FeedGroupViewModel>();
            Modify = ReactiveCommand.CreateFromTask(_navigationService.Navigate <ChannelViewModel>);
            Load   = ReactiveCommand.CreateFromTask(_categoryManager.GetAll);
            Load.Select(categories => categories.Select(_factory))
            .ObserveOn(RxApp.MainThreadScheduler)
            .Do(models => Items.Clear())
            .Subscribe(Items.AddRange);

            Load.IsExecuting.Skip(1)
            .Subscribe(x => IsLoading = x);
            Items.IsEmptyChanged
            .Subscribe(x => IsEmpty = x);
            Items.Changed
            .Select(args => Items.FirstOrDefault())
            .Where(selection => selection != null)
            .Subscribe(x => Selection = x);

            Load.IsExecuting
            .Where(executing => executing)
            .Select(executing => false)
            .Subscribe(x => HasErrors = x);
            Load.ThrownExceptions
            .Select(exception => true)
            .ObserveOn(RxApp.MainThreadScheduler)
            .Subscribe(x => HasErrors = x);

            Activator = new ViewModelActivator();
            this.WhenActivated((CompositeDisposable disposables) =>
                               Load.Execute().Subscribe());
        }
 void SendMessages() => Load.Execute(null);
Example #9
0
        static void Prompt()
        {
            // If the directory nor the files exist, create them
            if (!Directory.Exists(copyPath))
            {
                Directory.CreateDirectory(copyPath);
            }
            if (!File.Exists(copyPath + "\\copylist.tute"))
            {
                File.Create(copyPath + "\\copylist.tute").Close();
            }

            while (!done)
            {
                Console.Write($"#{line} ");
                string   command  = Console.ReadLine();
                string[] args     = command.Split(new[] { ' ' }, 2);
                string[] argsFull = command.Split(' ');    // Ask for a command, split it into two arrays, one where it only splits once and one when it constantly splits
                char[]   check    = args[0].ToCharArray(); // Convert the first argument of args into a char array
                switch (args[0])
                {
                case "/save":
                    var Save = new Save();
                    Save.ParseArgs(argsFull);
                    Save.Execute();
                    break;

                case "/load":
                    var Load = new Load();
                    Load.ParseArgs(argsFull);
                    Load.Execute();
                    break;

                case "/undo":
                    var Undo = new Undo();
                    Undo.Execute();
                    break;

                case "/redo":
                    var Redo = new Redo();
                    Redo.Execute();
                    break;

                case "/copy":
                    var Copy = new Copy();
                    Copy.ParseArgs(argsFull);
                    Copy.Execute();
                    break;

                case "/paste":
                    var Paste        = new Paste();
                    var PasteReplace = new PasteReplace();
                    if ((argsFull.Length == 3) && (argsFull[1] == "r")) // if there are 3 arguments and the second one is r
                    {
                        PasteReplace.ParseArgs(argsFull);
                        PasteReplace.Execute();
                    }
                    else if ((argsFull.Length == 2) && (argsFull[1] == "a")) // if there are two arguments and the second one is a
                    {
                        Paste.ParseArgs(argsFull);
                        Paste.Execute();
                    }
                    else
                    {
                        Console.WriteLine(argError);
                    }
                    break;

                case "/dis":
                    var Display = new Display();
                    Display.Execute();
                    break;

                case "/edit":
                    var Edit = new Edit();
                    Edit.ParseArgs(argsFull);
                    Edit.Execute();
                    break;

                case "/move":
                    var Move = new Move();
                    Move.ParseArgs(argsFull);
                    Move.Execute();
                    break;

                case "/del":
                    var Delete = new Delete();
                    Delete.ParseArgs(argsFull);
                    Delete.Execute();
                    break;

                case "/clear":
                    Console.Clear();
                    break;

                case "/exit":
                    var Exit = new Exit();
                    Exit.ParseArgs(args);
                    Exit.Execute();
                    break;

                default:
                    string fullCommand;                        // Initialize a full command string
                    if (args.Length > 1)                       // if args has more than one argument
                    {
                        fullCommand = args[0] + " " + args[1]; // the full command is the argument 0, plus a space, plus the rest
                    }
                    else
                    {
                        fullCommand = args[0]; // else its just the arg 0
                    }

                    if (check[0] == '/') // check if the char array made before has as its first letter a /
                    {
                        Console.WriteLine(syntaxError);
                    }
                    else
                    {
                        lines.Add(fullCommand); // add the command to the lines list
                        line++;                 // increment the lines counter
                    }
                    hasSaved = false;
                    break;
                }
            }
        }