Skip to content

Commit e78a44e

Browse files
baxcodersangularsen
authored andcommitted
Add SolidAngle, ThermalConductivity (#369)
SolidAngle - Steradian (sr) ThermalConductivity - WattPerMeterKelvin (W/m·K)
1 parent fd2548e commit e78a44e

14 files changed

+2134
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated (once) by \generate-code.bat, but will not be
4+
// regenerated when it already exists. The purpose of creating this file is to make
5+
// it easier to remember to implement all the unit conversion test cases.
6+
//
7+
// Whenever a new unit is added to this quantity and \generate-code.bat is run,
8+
// the base test class will get a new abstract property and cause a compile error
9+
// in this derived class, reminding the developer to implement the test case
10+
// for the new unit.
11+
//
12+
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
13+
//
14+
// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
15+
// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
16+
// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
17+
//
18+
// </auto-generated>
19+
//------------------------------------------------------------------------------
20+
21+
// Copyright (c) 2013 Andreas Gullberg Larsen ([email protected]).
22+
// https://github.com/angularsen/UnitsNet
23+
//
24+
// Permission is hereby granted, free of charge, to any person obtaining a copy
25+
// of this software and associated documentation files (the "Software"), to deal
26+
// in the Software without restriction, including without limitation the rights
27+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28+
// copies of the Software, and to permit persons to whom the Software is
29+
// furnished to do so, subject to the following conditions:
30+
//
31+
// The above copyright notice and this permission notice shall be included in
32+
// all copies or substantial portions of the Software.
33+
//
34+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40+
// THE SOFTWARE.
41+
42+
43+
using System;
44+
45+
namespace UnitsNet.Tests.CustomCode
46+
{
47+
public class SolidAngleTests : SolidAngleTestsBase
48+
{
49+
protected override double SteradiansInOneSteradian => 1;
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated (once) by \generate-code.bat, but will not be
4+
// regenerated when it already exists. The purpose of creating this file is to make
5+
// it easier to remember to implement all the unit conversion test cases.
6+
//
7+
// Whenever a new unit is added to this quantity and \generate-code.bat is run,
8+
// the base test class will get a new abstract property and cause a compile error
9+
// in this derived class, reminding the developer to implement the test case
10+
// for the new unit.
11+
//
12+
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
13+
//
14+
// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
15+
// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
16+
// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
17+
//
18+
// </auto-generated>
19+
//------------------------------------------------------------------------------
20+
21+
// Copyright (c) 2013 Andreas Gullberg Larsen ([email protected]).
22+
// https://github.com/angularsen/UnitsNet
23+
//
24+
// Permission is hereby granted, free of charge, to any person obtaining a copy
25+
// of this software and associated documentation files (the "Software"), to deal
26+
// in the Software without restriction, including without limitation the rights
27+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28+
// copies of the Software, and to permit persons to whom the Software is
29+
// furnished to do so, subject to the following conditions:
30+
//
31+
// The above copyright notice and this permission notice shall be included in
32+
// all copies or substantial portions of the Software.
33+
//
34+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40+
// THE SOFTWARE.
41+
42+
43+
using System;
44+
45+
namespace UnitsNet.Tests.CustomCode
46+
{
47+
public class ThermalConductivityTests : ThermalConductivityTestsBase
48+
{
49+
protected override double WattsPerMeterKelvinInOneWattPerMeterKelvin => 1;
50+
}
51+
}
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
//------------------------------------------------------------------------------
2+
// <auto-generated>
3+
// This code was generated by \generate-code.bat.
4+
//
5+
// Changes to this file will be lost when the code is regenerated.
6+
// The build server regenerates the code before each build and a pre-build
7+
// step will regenerate the code on each local build.
8+
//
9+
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
10+
//
11+
// Add CustomCode\Quantities\MyUnit.extra.cs files to add code to generated quantities.
12+
// Add Extensions\MyUnitExtensions.cs to decorate quantities with new behavior.
13+
// Add UnitDefinitions\MyUnit.json and run GeneratUnits.bat to generate new units or quantities.
14+
//
15+
// </auto-generated>
16+
//------------------------------------------------------------------------------
17+
18+
// Copyright (c) 2013 Andreas Gullberg Larsen ([email protected]).
19+
// https://github.com/angularsen/UnitsNet
20+
//
21+
// Permission is hereby granted, free of charge, to any person obtaining a copy
22+
// of this software and associated documentation files (the "Software"), to deal
23+
// in the Software without restriction, including without limitation the rights
24+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25+
// copies of the Software, and to permit persons to whom the Software is
26+
// furnished to do so, subject to the following conditions:
27+
//
28+
// The above copyright notice and this permission notice shall be included in
29+
// all copies or substantial portions of the Software.
30+
//
31+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37+
// THE SOFTWARE.
38+
39+
using System;
40+
using UnitsNet.Units;
41+
using Xunit;
42+
43+
// Disable build warning CS1718: Comparison made to same variable; did you mean to compare something else?
44+
#pragma warning disable 1718
45+
46+
// ReSharper disable once CheckNamespace
47+
namespace UnitsNet.Tests
48+
{
49+
/// <summary>
50+
/// Test of SolidAngle.
51+
/// </summary>
52+
// ReSharper disable once PartialTypeWithSinglePart
53+
public abstract partial class SolidAngleTestsBase
54+
{
55+
protected abstract double SteradiansInOneSteradian { get; }
56+
57+
// ReSharper disable VirtualMemberNeverOverriden.Global
58+
protected virtual double SteradiansTolerance { get { return 1e-5; } }
59+
// ReSharper restore VirtualMemberNeverOverriden.Global
60+
61+
[Fact]
62+
public void SteradianToSolidAngleUnits()
63+
{
64+
SolidAngle steradian = SolidAngle.FromSteradians(1);
65+
AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.Steradians, SteradiansTolerance);
66+
}
67+
68+
[Fact]
69+
public void FromValueAndUnit()
70+
{
71+
AssertEx.EqualTolerance(1, SolidAngle.From(1, SolidAngleUnit.Steradian).Steradians, SteradiansTolerance);
72+
}
73+
74+
[Fact]
75+
public void As()
76+
{
77+
var steradian = SolidAngle.FromSteradians(1);
78+
AssertEx.EqualTolerance(SteradiansInOneSteradian, steradian.As(SolidAngleUnit.Steradian), SteradiansTolerance);
79+
}
80+
81+
[Fact]
82+
public void ConversionRoundTrip()
83+
{
84+
SolidAngle steradian = SolidAngle.FromSteradians(1);
85+
AssertEx.EqualTolerance(1, SolidAngle.FromSteradians(steradian.Steradians).Steradians, SteradiansTolerance);
86+
}
87+
88+
[Fact]
89+
public void ArithmeticOperators()
90+
{
91+
SolidAngle v = SolidAngle.FromSteradians(1);
92+
AssertEx.EqualTolerance(-1, -v.Steradians, SteradiansTolerance);
93+
AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(3)-v).Steradians, SteradiansTolerance);
94+
AssertEx.EqualTolerance(2, (v + v).Steradians, SteradiansTolerance);
95+
AssertEx.EqualTolerance(10, (v*10).Steradians, SteradiansTolerance);
96+
AssertEx.EqualTolerance(10, (10*v).Steradians, SteradiansTolerance);
97+
AssertEx.EqualTolerance(2, (SolidAngle.FromSteradians(10)/5).Steradians, SteradiansTolerance);
98+
AssertEx.EqualTolerance(2, SolidAngle.FromSteradians(10)/SolidAngle.FromSteradians(5), SteradiansTolerance);
99+
}
100+
101+
[Fact]
102+
public void ComparisonOperators()
103+
{
104+
SolidAngle oneSteradian = SolidAngle.FromSteradians(1);
105+
SolidAngle twoSteradians = SolidAngle.FromSteradians(2);
106+
107+
Assert.True(oneSteradian < twoSteradians);
108+
Assert.True(oneSteradian <= twoSteradians);
109+
Assert.True(twoSteradians > oneSteradian);
110+
Assert.True(twoSteradians >= oneSteradian);
111+
112+
Assert.False(oneSteradian > twoSteradians);
113+
Assert.False(oneSteradian >= twoSteradians);
114+
Assert.False(twoSteradians < oneSteradian);
115+
Assert.False(twoSteradians <= oneSteradian);
116+
}
117+
118+
[Fact]
119+
public void CompareToIsImplemented()
120+
{
121+
SolidAngle steradian = SolidAngle.FromSteradians(1);
122+
Assert.Equal(0, steradian.CompareTo(steradian));
123+
Assert.True(steradian.CompareTo(SolidAngle.Zero) > 0);
124+
Assert.True(SolidAngle.Zero.CompareTo(steradian) < 0);
125+
}
126+
127+
[Fact]
128+
public void CompareToThrowsOnTypeMismatch()
129+
{
130+
SolidAngle steradian = SolidAngle.FromSteradians(1);
131+
Assert.Throws<ArgumentException>(() => steradian.CompareTo(new object()));
132+
}
133+
134+
[Fact]
135+
public void CompareToThrowsOnNull()
136+
{
137+
SolidAngle steradian = SolidAngle.FromSteradians(1);
138+
Assert.Throws<ArgumentNullException>(() => steradian.CompareTo(null));
139+
}
140+
141+
142+
[Fact]
143+
public void EqualityOperators()
144+
{
145+
SolidAngle a = SolidAngle.FromSteradians(1);
146+
SolidAngle b = SolidAngle.FromSteradians(2);
147+
148+
// ReSharper disable EqualExpressionComparison
149+
Assert.True(a == a);
150+
Assert.True(a != b);
151+
152+
Assert.False(a == b);
153+
Assert.False(a != a);
154+
// ReSharper restore EqualExpressionComparison
155+
}
156+
157+
[Fact]
158+
public void EqualsIsImplemented()
159+
{
160+
SolidAngle v = SolidAngle.FromSteradians(1);
161+
Assert.True(v.Equals(SolidAngle.FromSteradians(1), SolidAngle.FromSteradians(SteradiansTolerance)));
162+
Assert.False(v.Equals(SolidAngle.Zero, SolidAngle.FromSteradians(SteradiansTolerance)));
163+
}
164+
165+
[Fact]
166+
public void EqualsReturnsFalseOnTypeMismatch()
167+
{
168+
SolidAngle steradian = SolidAngle.FromSteradians(1);
169+
Assert.False(steradian.Equals(new object()));
170+
}
171+
172+
[Fact]
173+
public void EqualsReturnsFalseOnNull()
174+
{
175+
SolidAngle steradian = SolidAngle.FromSteradians(1);
176+
Assert.False(steradian.Equals(null));
177+
}
178+
}
179+
}

0 commit comments

Comments
 (0)