async Task <IFactReport> GetReportAsync(CancellationToken cancellation) { cancellation.ThrowIfCancellationRequested(); var report = new FactReport(); var meters = await _meterRepository .GetAllAsync(cancellation) .ConfigureAwait(false); if (meters == null) { report.IsSuccessful = false; return(report); } foreach (var meter in meters.Where(m => _meterValidator.Validate(m))) { var metric = await meter.ReadAsync(cancellation).ConfigureAwait(false); if (metric != null) { report.AddFact(metric); } cancellation.ThrowIfCancellationRequested(); } report.IsSuccessful = true; return(report); }
public static void ExamineFactDifferences() { // load same instance twice var path = Path.Combine("data", "ars.xbrl"); var firstInstance = Instance.FromFile(path); var secondInstance = Instance.FromFile(path); // change some facts on the second instance firstInstance.Facts[0].Value = "DEADBEED"; firstInstance.Facts[1].Decimals = "16"; secondInstance.Facts[0].Value = "FOOBAR"; secondInstance.Facts[1].Decimals = "9"; // change some context members secondInstance.Contexts[4].AddExplicitMember("AO", "s2c_AO:x0"); secondInstance.Contexts[5].AddExplicitMember("RT", "s2c_RT:x52"); // generate raw differences var report = InstanceComparer.ReportObjects(firstInstance, secondInstance, ComparisonTypes.All, BasicComparisons.All); // should give negative result because differences were found Assert.False(report.Result); // should report both facts for both instances Assert.Equal(2, report.Facts.Item1.Count); Assert.Equal(2, report.Facts.Item2.Count); // try to match the facts var factReport = FactReport.FromReport(report); Assert.NotNull(factReport.Matches); }