/// <summary> /// Sets the actual rows specified by <paramref name="actualRowsProvider"/> parameter and verifies them against expectations.<br/> /// If evaluation of <paramref name="actualRowsProvider"/> throws, the exception will be included in the report, but won't be propagated out of this method. /// </summary> /// <param name="actualRowsProvider">Actual rows provider.</param> /// <returns>Self.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="actualRowsProvider"/> is null.</exception> /// <exception cref="InvalidOperationException">Thrown if <see cref="ActualRows"/> collection has been already set.</exception> public async Task SetActualAsync(Func <Task <IEnumerable <TRow> > > actualRowsProvider) { if (actualRowsProvider == null) { throw new ArgumentNullException(nameof(actualRowsProvider)); } EnsureActualNotSet(); IEnumerable <TRow> actualCollection; try { actualCollection = await actualRowsProvider(); } catch (Exception ex) { _details = new TabularParameterDetails( GetColumnResults(), GetExpectedRowResults(), ParameterVerificationStatus.Exception, new InvalidOperationException($"Failed to retrieve rows: {ex.Message}", ex)); ActualRows = new TRow[0]; return; } SetActual(actualCollection); }
private ITabularParameterDetails GetResultLazily() { if (_details != null) { return(_details); } return(_details = new TabularParameterDetails(GetColumnResults(), GetExpectedRowResults(), ParameterVerificationStatus.NotProvided)); }
/// <summary> /// Sets specified <paramref name="rows"/> as the actual values and generates the details for it. /// </summary> /// <param name="rows">Rows to set.</param> protected void SetRows(IEnumerable <RowData> rows) { var dataRows = rows.ToArray(); _details = new TabularParameterDetails(GetColumnResults(), dataRows.Select(ToRowResult)); ActualRows = dataRows .Where(x => x.Type != TableRowType.Missing) .Select(x => x.Actual.Value) .ToArray(); }