public void Then_report_should_be_downloaded() { var fakeDownloader = A.Fake <IReportDownloader>(); var fakeSettings = A.Fake <ISettings>(); A.CallTo(() => fakeSettings.Address).Returns("http://localhost"); var command = new DownloadReportCommand(fakeDownloader, fakeSettings); command.Execute(null); A.CallTo(() => fakeDownloader.DownloadAsync(EventThread.CallingThread)).MustHaveHappened(Repeated.Exactly.Once); }
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_ReportDownloaded_event_should_be_raised() { var fakeDownloader = A.Fake <IReportDownloader>(); var fakeSettings = A.Fake <ISettings>(); A.CallTo(() => fakeSettings.Address).Returns("http://localhost"); var command = new DownloadReportCommand(fakeDownloader, fakeSettings); var eventRaised = false; command.ReportDownloaded += (sender, args) => { eventRaised = true; }; command.Execute(null); // Raise the event from the fake. var eventArgs = new DownloadCompletedEventArgs(new BandwidthReport(), null); fakeDownloader.DownloadCompleted += Raise.With(eventArgs).Now; Assert.IsTrue(eventRaised); }
public void Then_Daily_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.Daily.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); }
public ReportController(IHSReportCommand reportDataCommand, AppSettings settings, DownloadReportCommand downloadReportCommand) { _reportDataCommand = reportDataCommand; _downloadReportCommand = downloadReportCommand; }