Example #1
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);
        }
        public void Then_Monthly_values_should_be_empty()
        {
            var fakeDownloader = A.Fake<IReportDownloader>();
            var fakeSettings = A.Fake<ISettings>();
            A.CallTo(() => fakeSettings.Address).Returns("http://localhost");
            var command = new DownloadReportCommand(fakeDownloader, fakeSettings);

            var itemCount = 0;

            command.ReportDownloaded += (sender, args) =>
                {
                    itemCount = args.Monthly.Count();
                };

            command.Execute(null);

            // Raise the event from the fake.
            var eventArgs = new DownloadCompletedEventArgs(CreateReport(), new Exception());
            fakeDownloader.DownloadCompleted += Raise.With(eventArgs).Now;

            Assert.AreEqual(0, itemCount);
        }