Skip to content

Commit 13ecde0

Browse files
committed
Clean up code in Tests/CustomCode/.
* Run R# full clean up. * Add missing file headers.
1 parent 920953c commit 13ecde0

13 files changed

+278
-68
lines changed

Tests/CustomCode/AngleTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
using System;
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
using System;
223

324
namespace UnitsNet.Tests.net35.CustomCode
425
{

Tests/CustomCode/AreaTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace UnitsNet.Tests.net35.CustomCode
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
namespace UnitsNet.Tests.net35.CustomCode
223
{
324
public class AreaTests : AreaTestsBase
425
{

Tests/CustomCode/ElectricPotentialTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1919
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2020
// THE SOFTWARE.
21+
2122
namespace UnitsNet.Tests.net35.CustomCode
2223
{
2324
public class ElectricPotentialTests : ElectricPotentialTestsBase

Tests/CustomCode/FlowTests.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace UnitsNet.Tests.net35.CustomCode
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
namespace UnitsNet.Tests.net35.CustomCode
223
{
324
public class FlowTests : FlowTestsBase
425
{
@@ -12,4 +33,4 @@ public override double CubicMetersPerSecondInOneCubicMeterPerSecond
1233
get { return 1; }
1334
}
1435
}
15-
}
36+
}

Tests/CustomCode/ForceTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace UnitsNet.Tests.net35.CustomCode
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
namespace UnitsNet.Tests.net35.CustomCode
223
{
324
public class ForceTests : ForceTestsBase
425
{

Tests/CustomCode/Length2dTests.cs

Lines changed: 74 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
1-
// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else?
2-
#pragma warning disable 1718
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
321

422
using NUnit.Framework;
523

@@ -11,68 +29,21 @@ public class Length2dTests
1129
{
1230
private const double Delta = 1E-5;
1331

14-
[Test]
15-
public void MetersToDistanceUnits()
16-
{
17-
Length2d meter = Length2d.FromMeters(1,1);
18-
19-
AssertAreEqual(new Vector2(1), meter.Meters, Delta);
20-
AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
21-
AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
22-
AssertAreEqual(new Vector2(1E-3), meter.Kilometers, Delta);
23-
AssertAreEqual(new Vector2(1), meter.Meters, Delta);
24-
AssertAreEqual(new Vector2(1E1), meter.Decimeters, Delta);
25-
AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
26-
AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
27-
AssertAreEqual(new Vector2(1E6), meter.Micrometers, Delta);
28-
AssertAreEqual(new Vector2(1E9), meter.Nanometers, Delta);
29-
30-
Assert.AreEqual(0.000621371, meter.Miles.X, Delta);
31-
Assert.AreEqual(0.000621371, meter.Miles.Y, Delta);
32-
Assert.AreEqual(1.09361, meter.Yards.X, Delta);
33-
Assert.AreEqual(1.09361, meter.Yards.Y, Delta);
34-
Assert.AreEqual(3.28084, meter.Feet.X, Delta);
35-
Assert.AreEqual(3.28084, meter.Feet.Y, Delta);
36-
Assert.AreEqual(39.37007874, meter.Inches.X, Delta);
37-
Assert.AreEqual(39.37007874, meter.Inches.Y, Delta);
38-
}
39-
4032
private void AssertAreEqual(Vector2 expected, Vector2 actual, double delta)
41-
{
33+
{
4234
Assert.AreEqual(expected.X, actual.X, Delta);
4335
Assert.AreEqual(expected.Y, actual.Y, Delta);
4436
}
4537

46-
[Test]
47-
public void DistanceUnitsRoundTrip()
48-
{
49-
Length meter = Length.FromMeters(1);
50-
51-
Assert.AreEqual(1, Length.FromKilometers(meter.Kilometers).Meters, Delta);
52-
Assert.AreEqual(1, Length.FromMeters(meter.Meters).Meters, Delta);
53-
Assert.AreEqual(1, Length.FromDecimeters(meter.Decimeters).Meters, Delta);
54-
Assert.AreEqual(1, Length.FromCentimeters(meter.Centimeters).Meters, Delta);
55-
Assert.AreEqual(1, Length.FromMillimeters(meter.Millimeters).Meters, Delta);
56-
Assert.AreEqual(1, Length.FromMicrometers(meter.Micrometers).Meters, Delta);
57-
Assert.AreEqual(1, Length.FromNanometers(meter.Nanometers).Meters, Delta);
58-
}
59-
60-
[Test]
61-
public void VectorLength()
62-
{
63-
var v = new Length2d(3, 4);
64-
Assert.AreEqual(5, v.Length.Meters);
65-
}
66-
6738

6839
[Test]
6940
public void ArithmeticOperators()
7041
{
7142
Length2d v = Length2d.FromMeters(1, 2);
7243
Assert.AreEqual(-1, -v.Meters.X, Delta);
7344
Assert.AreEqual(-2, -v.Meters.Y, Delta);
74-
Assert.AreEqual(2, (Length2d.FromMeters(3, 3)-v).Meters.X, Delta);
75-
Assert.AreEqual(1, (Length2d.FromMeters(3, 3)-v).Meters.Y, Delta);
45+
Assert.AreEqual(2, (Length2d.FromMeters(3, 3) - v).Meters.X, Delta);
46+
Assert.AreEqual(1, (Length2d.FromMeters(3, 3) - v).Meters.Y, Delta);
7647
Assert.AreEqual(2, (v + v).Meters.X, Delta);
7748
Assert.AreEqual(4, (v + v).Meters.Y, Delta);
7849
Assert.AreEqual(10, (v*10).Meters.X, Delta);
@@ -87,14 +58,28 @@ public void ArithmeticOperators()
8758
Assert.AreEqual(4, (Length2d.FromMeters(10, 20)/Length2d.FromMeters(5, 5)).Y, Delta);
8859
}
8960

61+
[Test]
62+
public void DistanceUnitsRoundTrip()
63+
{
64+
Length meter = Length.FromMeters(1);
65+
66+
Assert.AreEqual(1, Length.FromKilometers(meter.Kilometers).Meters, Delta);
67+
Assert.AreEqual(1, Length.FromMeters(meter.Meters).Meters, Delta);
68+
Assert.AreEqual(1, Length.FromDecimeters(meter.Decimeters).Meters, Delta);
69+
Assert.AreEqual(1, Length.FromCentimeters(meter.Centimeters).Meters, Delta);
70+
Assert.AreEqual(1, Length.FromMillimeters(meter.Millimeters).Meters, Delta);
71+
Assert.AreEqual(1, Length.FromMicrometers(meter.Micrometers).Meters, Delta);
72+
Assert.AreEqual(1, Length.FromNanometers(meter.Nanometers).Meters, Delta);
73+
}
74+
9075
[Test]
9176
public void EqualityOperators()
9277
{
9378
Length2d a = Length2d.FromMeters(1, 2);
9479
Length2d b = Length2d.FromMeters(2, 1);
9580

9681
// ReSharper disable EqualExpressionComparison
97-
Assert.True(a == a);
82+
Assert.True(a == a);
9883
Assert.True(a != b);
9984

10085
Assert.False(a == b);
@@ -110,6 +95,13 @@ public void EqualsIsImplemented()
11095
Assert.IsFalse(v.Equals(Length2d.Zero));
11196
}
11297

98+
[Test]
99+
public void EqualsReturnsFalseOnNull()
100+
{
101+
Length2d newton = Length2d.FromMeters(1, 2);
102+
Assert.IsFalse(newton.Equals(null));
103+
}
104+
113105
[Test]
114106
public void EqualsReturnsFalseOnTypeMismatch()
115107
{
@@ -118,10 +110,36 @@ public void EqualsReturnsFalseOnTypeMismatch()
118110
}
119111

120112
[Test]
121-
public void EqualsReturnsFalseOnNull()
113+
public void MetersToDistanceUnits()
122114
{
123-
Length2d newton = Length2d.FromMeters(1, 2);
124-
Assert.IsFalse(newton.Equals(null));
115+
Length2d meter = Length2d.FromMeters(1, 1);
116+
117+
AssertAreEqual(new Vector2(1), meter.Meters, Delta);
118+
AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
119+
AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
120+
AssertAreEqual(new Vector2(1E-3), meter.Kilometers, Delta);
121+
AssertAreEqual(new Vector2(1), meter.Meters, Delta);
122+
AssertAreEqual(new Vector2(1E1), meter.Decimeters, Delta);
123+
AssertAreEqual(new Vector2(1E2), meter.Centimeters, Delta);
124+
AssertAreEqual(new Vector2(1E3), meter.Millimeters, Delta);
125+
AssertAreEqual(new Vector2(1E6), meter.Micrometers, Delta);
126+
AssertAreEqual(new Vector2(1E9), meter.Nanometers, Delta);
127+
128+
Assert.AreEqual(0.000621371, meter.Miles.X, Delta);
129+
Assert.AreEqual(0.000621371, meter.Miles.Y, Delta);
130+
Assert.AreEqual(1.09361, meter.Yards.X, Delta);
131+
Assert.AreEqual(1.09361, meter.Yards.Y, Delta);
132+
Assert.AreEqual(3.28084, meter.Feet.X, Delta);
133+
Assert.AreEqual(3.28084, meter.Feet.Y, Delta);
134+
Assert.AreEqual(39.37007874, meter.Inches.X, Delta);
135+
Assert.AreEqual(39.37007874, meter.Inches.Y, Delta);
136+
}
137+
138+
[Test]
139+
public void VectorLength()
140+
{
141+
var v = new Length2d(3, 4);
142+
Assert.AreEqual(5, v.Length.Meters);
125143
}
126144
}
127145
}

Tests/CustomCode/LengthTests.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace UnitsNet.Tests.net35.CustomCode
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
namespace UnitsNet.Tests.net35.CustomCode
223
{
324
public class LengthTests : LengthTestsBase
425
{
@@ -19,7 +40,7 @@ public override double FeetInOneMeter
1940

2041
public override double InchesInOneMeter
2142
{
22-
get { return 39.37007874; }
43+
get { return 39.37007874; }
2344
}
2445

2546
public override double KilometersInOneMeter

Tests/CustomCode/MassTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace UnitsNet.Tests.net35.CustomCode
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
namespace UnitsNet.Tests.net35.CustomCode
223
{
324
public class MassTests : MassTestsBase
425
{

Tests/CustomCode/PressureTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
namespace UnitsNet.Tests.net35.CustomCode
1+
// Copyright © 2007 by Initial Force AS. All rights reserved.
2+
// https://github.com/InitialForce/UnitsNet
3+
//
4+
// Permission is hereby granted, free of charge, to any person obtaining a copy
5+
// of this software and associated documentation files (the "Software"), to deal
6+
// in the Software without restriction, including without limitation the rights
7+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
// copies of the Software, and to permit persons to whom the Software is
9+
// furnished to do so, subject to the following conditions:
10+
//
11+
// The above copyright notice and this permission notice shall be included in
12+
// all copies or substantial portions of the Software.
13+
//
14+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
// THE SOFTWARE.
21+
22+
namespace UnitsNet.Tests.net35.CustomCode
223
{
324
public class PressureTests : PressureTestsBase
425
{

0 commit comments

Comments
 (0)