Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }