Repository navigation
Expand file tree
/
Copy pathLevelTests.cs
More file actions
45 lines (38 loc) · 1.61 KB
/
Copy pathLevelTests.cs
File metadata and controls
45 lines (38 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Licensed under MIT No Attribution, see LICENSE file at the root.
// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet.
using System;
using Xunit;
namespace UnitsNet.Tests
{
public class LevelTests : LevelTestsBase
{
protected override double DecibelsInOneDecibel => 1;
protected override double NepersInOneDecibel => 0.115129254;
protected override void AssertLogarithmicAddition()
{
Level v = Level.FromDecibels(40);
AssertEx.EqualTolerance(43.0102999566, (v + v).Decibels, DecibelsTolerance);
}
protected override void AssertLogarithmicSubtraction()
{
Level v = Level.FromDecibels(40);
AssertEx.EqualTolerance(49.5424250944, (Level.FromDecibels(50) - v).Decibels, DecibelsTolerance);
}
[Theory]
[InlineData(0, 1)]
[InlineData(-1, 1)]
public void InvalidQuantity_ExpectArgumentOutOfRangeException(double quantity, double reference)
{
// quantity can't be zero or less than zero if reference is positive.
Assert.Throws<ArgumentOutOfRangeException>(() => new Level(quantity, reference));
}
[Theory]
[InlineData(1, 0)]
[InlineData(10, -1)]
public void InvalidReference_ExpectArgumentOutOfRangeException(double quantity, double reference)
{
// reference can't be zero or less than zero if quantity is postive.
Assert.Throws<ArgumentOutOfRangeException>(() => new Level(quantity, reference));
}
}
}