Пример #1
0
        public void BuildReportTest(WeatherRecord current, DateTime lastRainyDay, FireHazardReport expectedReport)
        {
            var manager = new Mock <IWeatherRecordManager>();

            manager.Setup(
                recordManager => recordManager.GetLastRainyDay(current.LocationId.Value, It.IsAny <DateTime>(), It.IsAny <DateTime>()))
            .Returns(lastRainyDay);

            var builder = new FireHazardReportBuilder(manager.Object);

            var actualReport = builder.BuildReport(current);

            Assert.Equal(expectedReport.FireHazardCoefficient, actualReport.FireHazardCoefficient, 0);
        }
Пример #2
0
        private void ExecuteBuildReport(WeatherRecord record)
        {
            var buildTask = Task.Run(() =>
            {
                var b      = new FireHazardReportBuilder(_weatherRecordManager);
                var report = b.BuildReport(record);
                return(report);
            });

            buildTask.ContinueWith(DispatchError);
            buildTask.ContinueWith(task =>
            {
                if (task.IsFaulted || task.IsCanceled)
                {
                    return;
                }

                DispatcherHelper.CheckBeginInvokeOnUI(() => NavigationService.NavigateTo(Dialogs.ReportBuilder, task.Result));
            });
        }