Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
#1 Added some more Debug.Assert() for DataSetAggregator
Browse files Browse the repository at this point in the history
  • Loading branch information
arepetti committed Feb 20, 2017
1 parent 2001d03 commit d011665
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/src/OpenBlackboard.Model/DataSetAggregator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public DataSet Calculate()
{
Debug.Assert(_protocol != null);
Debug.Assert(_accumulator != null);
Debug.Assert(_accumulator.IsEmpty || _culture != null);

var result = new DataSet(_protocol);

Expand All @@ -148,6 +149,9 @@ public DataSet Calculate()

private object Transform(DataSet dataset, ValueDescriptor descriptor, object value)
{
Debug.Assert(dataset != null);
Debug.Assert(descriptor != null);

if (String.IsNullOrWhiteSpace(descriptor.TransformationForAggregationExpression))
return value;

Expand All @@ -163,6 +167,9 @@ private object Transform(DataSet dataset, ValueDescriptor descriptor, object val

private IEnumerable<object> Filter(ValueDescriptor descriptor, IEnumerable<object> values)
{
Debug.Assert(descriptor != null);
Debug.Assert(values != null);

if (descriptor.PreferredAggregation == AggregationMode.Count && Options.HasFlag(AggregationOptions.ExcludeNullValuesFromCount))
return values.Where(x => x != null);

Expand All @@ -171,6 +178,10 @@ private IEnumerable<object> Filter(ValueDescriptor descriptor, IEnumerable<objec

private object Aggregate(DataSet dataset, ValueDescriptor descriptor, IEnumerable<object> values)
{
Debug.Assert(descriptor != null);
Debug.Assert(values != null);
Debug.Assert(_accumulator.IsEmpty || _culture != null);

if (!String.IsNullOrWhiteSpace(descriptor.AggregationExpression))
{
var evaluator = new ExpressionEvaluator(dataset);
Expand Down
4 changes: 4 additions & 0 deletions src/src/OpenBlackboard.Model/DataSetValueAccumulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace OpenBlackboard.Model
{
sealed class DataSetValueAccumulator
{
public bool IsEmpty => _items.Count == 0;

public IEnumerable<object> this[ValueDescriptor descriptor]
{
get
Expand Down Expand Up @@ -47,6 +49,8 @@ public void AddRange(IEnumerable<DataSetValue> values)

public void Clear()
{
Debug.Assert(_items != null);

_items.Clear();
}

Expand Down

0 comments on commit d011665

Please sign in to comment.