/// <summary>
        /// Initializes a new instance of the <see cref="MainViewModel"/> class.
        /// </summary>
        /// <param name="downloadReportCommand">
        /// The download report command.
        /// </param>
        /// <param name="ignoreCommand">
        /// The ignore command.
        /// </param>
        /// <param name="openUriCommand">
        /// The open uri command.
        /// </param>
        /// <param name="clipboardCommand">
        /// The clipboard command.
        /// </param>
        /// <param name="daily">
        /// The daily.
        /// </param>
        /// <param name="monthly">
        /// The monthly.
        /// </param>
        /// <param name="settingsViewModel">Settings viewmodel.</param>
        public MainViewModel(
            IDownloadReportCommand downloadReportCommand,
            IBaseCommand ignoreCommand,
            OpenUriCommand openUriCommand,
            IBaseCommand clipboardCommand,
            DailyViewModel daily,
            MonthlyViewModel monthly,
            SettingsViewModel settingsViewModel)
        {
            downloadReportCommand.ReportDownloaded += this.ReportDownloaded;
            downloadReportCommand.Executing        += (sender, args) =>
            {
                this.IsBusy = true;
            };
            this.DownloadReportCommand = downloadReportCommand;

            ignoreCommand.Executed += (sender, args) =>
            {
                this.Error = null;
            };
            this.IgnoreCommand = ignoreCommand;

            this.OpenUriCommand   = openUriCommand;
            this.ClipboardCommand = clipboardCommand;

            this.daily    = daily;
            this.monthly  = monthly;
            this.settings = settingsViewModel;
        }
Beispiel #2
0
        public void DisallowsExecutionForStringDoesnNotContainingAbsoluteUri()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            Assert.IsFalse(openUriCommand.CanExecute("string1"));
            Assert.IsFalse(openUriCommand.CanExecute("contactchart/appearance"));
            Assert.IsFalse(openUriCommand.CanExecute("/contactchart/appearance"));
        }
Beispiel #3
0
        public void AllowsExecutionForStringContainingUri()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            Assert.IsTrue(openUriCommand.CanExecute("http://anysiteinstring.com"));
            Assert.IsTrue(openUriCommand.CanExecute("tst://tab/contactchart/appearance"));
            Assert.IsTrue(openUriCommand.CanExecute("E:/Work/Phoenix256/PhoenixSrc/Client"));
        }
Beispiel #4
0
        public void AllowsExecutionForAnyUri()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            Assert.IsTrue(openUriCommand.CanExecute(new Uri("http://anysite.com")));
            Assert.IsTrue(openUriCommand.CanExecute(new Uri("tst://tab/contactchart/primary")));
            Assert.IsTrue(openUriCommand.CanExecute(new Uri("D:/Work/Phoenix/PhoenixSrc/Client")));
        }
Beispiel #5
0
        public void OpensStringContainingShellUriAsIs()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            openUriCommand.Execute("tst://external/arm/log");

            this._shell.Received(1).Resolve(new Uri("tst://external/arm/log"));
            this._shellResolve.Received(1).Open();
        }
Beispiel #6
0
        public void OpensShellUriAsIs()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            openUriCommand.Execute(new Uri("tst://tab/contactchart/tools"));

            this._shell.Received(1).Resolve(new Uri("tst://tab/contactchart/tools"));
            this._shellResolve.Received(1).Open();
        }
Beispiel #7
0
        public void OpensNonShellUriUsingArmOpen()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            openUriCommand.Execute(new Uri("E:/Tests/Opens/String/Contains Something"));

            var expectedUriString = string.Format(
                "tst://external/arm/open?fileName={0}",
                Uri.EscapeDataString("file:///E:/Tests/Opens/String/Contains Something"));

            this._shell.Received(1).Resolve(new Uri(expectedUriString));
            this._shellResolve.Received(1).Open();
        }
Beispiel #8
0
        public void OpensStringContainingNonShellUriUsingArmOpen()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            openUriCommand.Execute("http://address-to-any-site.com/index.htm?data=091&p==145");

            var expectedUriString = string.Format(
                "tst://external/arm/open?fileName={0}",
                Uri.EscapeDataString("http://address-to-any-site.com/index.htm?data=091&p==145"));

            this._shell.Received(1).Resolve(new Uri(expectedUriString));
            this._shellResolve.Received(1).Open();
        }
Beispiel #9
0
        private void InitializeMainWindow()
        {
            var settings = new Settings();

            var downlodReportCommand = new DownloadReportCommand(new ReportDownloader(), settings);

            var daily             = new DailyViewModel(downlodReportCommand);
            var monthly           = new MonthlyViewModel(downlodReportCommand);
            var settingsViewmodel = new SettingsViewModel(settings);

            var ignoreCommand    = new Command();
            var openUriCommand   = new OpenUriCommand();
            var clipboardCommand = new CopyErrorReportToClipboardCommand(new SystemClipboard());

            this.MainWindow = new MainWindow();

            this.MainWindow.DataContext = new MainViewModel(downlodReportCommand, ignoreCommand, openUriCommand, clipboardCommand, daily, monthly, settingsViewmodel);
        }
Beispiel #10
0
        public void DisallowsExecutionForNull()
        {
            var openUriCommand = new OpenUriCommand(this._shell);

            Assert.IsFalse(openUriCommand.CanExecute(null));
        }