Skip to content

Commit 65b2397

Browse files
author
Erik Ovegard
committed
Code reviewed, added copyright headers and some more * overloading
1 parent 87a1505 commit 65b2397

20 files changed

+315
-80
lines changed

UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@
6767
<Name>UnitsNet.Net35</Name>
6868
</ProjectReference>
6969
</ItemGroup>
70-
<ItemGroup>
71-
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
72-
</ItemGroup>
7370
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7471
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
7572
Other similar extension points exist, see Microsoft.Common.targets.

UnitsNet.Tests/CustomCode/LengthTests.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ public void LengthTimesLengthEqualsArea()
3434
}
3535

3636
[Test]
37-
public void AreaTimesLengthEqualsArea()
37+
public void AreaTimesLengthEqualsVolume()
3838
{
3939
var volume = Area.FromSquareMeters(10) * Length.FromMeters(3);
4040
Assert.AreEqual(volume, Volume.FromCubicMeters(30));
4141
}
4242
[Test]
43-
public void LengthTimesAreaEqualsArea()
43+
public void LengthTimesAreaEqualsVolume()
4444
{
4545
var volume = Length.FromMeters(3) * Area.FromSquareMeters(9);
4646
Assert.AreEqual(volume, Volume.FromCubicMeters(27));
@@ -49,8 +49,15 @@ public void LengthTimesAreaEqualsArea()
4949
[Test]
5050
public void ForceTimesLengthEqualsTorque()
5151
{
52-
var volume = Length.FromMeters(3) * Area.FromSquareMeters(9);
53-
Assert.AreEqual(volume, Volume.FromCubicMeters(27));
52+
var torque = Force.FromNewtons(1) * Length.FromMeters(3);
53+
Assert.AreEqual(torque, Torque.FromNewtonMeters(3));
54+
}
55+
56+
[Test]
57+
public void LengthTimesForceEqualsTorque()
58+
{
59+
var torque = Length.FromMeters(3) * Force.FromNewtons(1);
60+
Assert.AreEqual(torque, Torque.FromNewtonMeters(3));
5461
}
5562

5663
protected override double CentimetersInOneMeter

UnitsNet.Tests/CustomCode/MassTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,21 @@ public void MassDividedByVolumeEqualsDensity()
3838
var density = Mass.FromKilograms(18) / Volume.FromCubicMeters(3);
3939
Assert.AreEqual(density, Density.FromKilogramsPerCubicMeter(6));
4040
}
41+
4142
[Test]
4243
public void MassTimesAccelerationEqualsForce()
4344
{
4445
var force = Mass.FromKilograms(18) * Acceleration.FromMeterPerSecondSquared(3);
4546
Assert.AreEqual(force, Force.FromNewtons(54));
4647
}
48+
49+
[Test]
50+
public void AccelerationTimesMassEqualsForce()
51+
{
52+
var force = Acceleration.FromMeterPerSecondSquared(3) * Mass.FromKilograms(18);
53+
Assert.AreEqual(force, Force.FromNewtons(54));
54+
}
55+
4756
protected override double CentigramsInOneKilogram
4857
{
4958
get { return 1E5; }

UnitsNet.Tests/CustomCode/PressureTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@ namespace UnitsNet.Tests.CustomCode
2424
{
2525
public class PressureTests : PressureTestsBase
2626
{
27-
28-
2927
[Test]
3028
public void PressureTimesAreaEqualsForce()
3129
{
3230
var force = Pressure.FromPascals(20) * Area.FromSquareMeters(3);
3331
Assert.AreEqual(force, Force.FromNewtons(60));
3432
}
3533

34+
[Test]
35+
public void AreaTimePressureEqualsForce()
36+
{
37+
var force = Area.FromSquareMeters(3) * Pressure.FromPascals(20);
38+
Assert.AreEqual(force, Force.FromNewtons(60));
39+
}
3640

3741
protected override double AtmospheresInOnePascal
3842
{

UnitsNet.Tests/CustomCode/RotationalSpeedTests.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,31 @@ public class RotationalSpeedTests : RotationalSpeedTestsBase
3030
[Test]
3131
public void RotationalSpeedTimesTimeSpanEqualsAngle()
3232
{
33-
var angle = RotationalSpeed.FromRadiansPerSecond(10.0)*TimeSpan.FromSeconds(9.0);
33+
var angle = RotationalSpeed.FromRadiansPerSecond(10.0) * TimeSpan.FromSeconds(9.0);
3434
Assert.AreEqual(angle, Angle.FromRadians(90.0));
3535
}
3636

37+
[Test]
38+
public void TimeSpanTimesRotationalSpeedEqualsAngle()
39+
{
40+
var angle = TimeSpan.FromSeconds(9.0) * RotationalSpeed.FromRadiansPerSecond(10.0) ;
41+
Assert.AreEqual(angle, Angle.FromRadians(90.0));
42+
}
43+
44+
[Test]
45+
public void RotationalSpeedTimesForceEqualsPower()
46+
{
47+
var power = RotationalSpeed.FromRadiansPerSecond(10.0) * Force.FromNewtons(2.0);
48+
Assert.AreEqual(power, Power.FromWatts(20.0));
49+
}
50+
51+
[Test]
52+
public void ForceTimesRotationalSpeedEqualsPower()
53+
{
54+
var power = Force.FromNewtons(2.0) * RotationalSpeed.FromRadiansPerSecond(10.0) ;
55+
Assert.AreEqual(power, Power.FromWatts(20.0));
56+
}
57+
3758
protected override double RadiansPerSecondInOneRevolutionPerSecond
3859
{
3960
get

UnitsNet.Tests/CustomCode/SpeedTests.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,28 +20,39 @@
2020
// THE SOFTWARE.
2121

2222
using System;
23-
2423
using NUnit.Framework;
25-
using System;
2624

2725
namespace UnitsNet.Tests.CustomCode
2826
{
2927
public class SpeedTests : SpeedTestsBase
3028
{
31-
3229
[Test]
3330
public void SpeedDevidedByTimespanEqualsAcceleration()
3431
{
3532
var acceleration = Speed.FromMetersPerSecond(20) / TimeSpan.FromSeconds(2);
3633
Assert.AreEqual(acceleration, Acceleration.FromMeterPerSecondSquared(10));
3734
}
35+
3836
[Test]
39-
public void SpeedTimesTimespanEqualsLength()
37+
public void SpeedTimesTimeSpanEqualsLength()
4038
{
4139
var length= Speed.FromMetersPerSecond(20) * TimeSpan.FromSeconds(2);
4240
Assert.AreEqual(length, Length.FromMeters(40));
4341
}
4442

43+
[Test]
44+
public void TimeSpanSpeedTimesEqualsLength()
45+
{
46+
var length = TimeSpan.FromSeconds(2) * Speed.FromMetersPerSecond(20);
47+
Assert.AreEqual(length, Length.FromMeters(40));
48+
}
49+
50+
[Test]
51+
public void LengthDividedByTimeSpanEqualsSpeed()
52+
{
53+
var speed = Length.FromMeters(20) / TimeSpan.FromSeconds(2);
54+
Assert.AreEqual(speed, Speed.FromMetersPerSecond(10));
55+
}
4556

4657
protected override double FeetPerSecondInOneMeterPerSecond
4758
{

UnitsNet.Tests/CustomCode/VolumeTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@ public void VolumeDividedByLengthEqualsArea()
3131
var area = Volume.FromCubicMeters(15) / Length.FromMeters(5);
3232
Assert.AreEqual(area, Area.FromSquareMeters(3));
3333
}
34+
3435
[Test]
3536
public void VolumeDividedByAreaEqualsLength()
3637
{
3738
var length= Volume.FromCubicMeters(15) / Area.FromSquareMeters(5);
3839
Assert.AreEqual(length, Length.FromMeters(3));
3940
}
41+
4042
[Test]
4143
public void VolumeTimesDensityEqualsMass()
4244
{

UnitsNet/CustomCode/UnitClasses/Angle.extra.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
425
{

UnitsNet/CustomCode/UnitClasses/Area.extra.cs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Globalization;
4-
using System.Linq;
5-
using System.Text;
6-
using UnitsNet.Units;
7-
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.
821

922
namespace UnitsNet
1023
{

UnitsNet/CustomCode/UnitClasses/Force.extra.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
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-
using UnitsNet.Units;
2221

2322
namespace UnitsNet
2423
{
@@ -40,8 +39,7 @@ public partial struct Force
4039
{
4140
return Pressure.FromPascals(force.Newtons / area.SquareMeters);
4241
}
43-
44-
42+
4543
public static Force FromPressureByArea(Pressure p, Length2d area)
4644
{
4745
double metersSquared = area.Meters.X*area.Meters.Y;

0 commit comments

Comments
 (0)