When_passing_null_measurements.cs
using NUnit.Framework;namespace Domain.Tests.AveragingCalculator_Tests.SadPath
{
[Category("AveragingCalculator")]
public class When_passing_null_measurements
{
private AveragingCalculator _averageCalculator;
[SetUp]
public void Setup()
{
_averageCalculator = new AveragingCalculator();
}
[Test]
[ExpectedException(typeof(ArgumentNullException))]
public void When_measurement_is_null()
{
var measurements = Mother.Get4Measurements();
measurements.Add(null);
_averageCalculator.Aggregate(measurements);
}
}
AveragingCalculator.cs
namespace Domain{
public class AveragingCalculator : IAggregateCalculator
{
if(measurements.Contains(null))
{
throw new ArgumentNullException();
}
return new Measurement()
{
HighValue=measurements.Average(m=>m.HighValue),
LowValue=measurements.Average(m=>m.LowValue)
};
}
No comments:
Post a Comment