Skip to content

Adding heat flux units with tests #431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions UnitsNet.Tests/CustomCode/HeatFluxTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated (once) by \generate-code.bat, but will not be
// regenerated when it already exists. The purpose of creating this file is to make
// it easier to remember to implement all the unit conversion test cases.
//
// Whenever a new unit is added to this quantity and \generate-code.bat is run,
// the base test class will get a new abstract property and cause a compile error
// in this derived class, reminding the developer to implement the test case
// for the new unit.
//
// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units.
//
// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities.
// Add Extensions\MyQuantityExtensions.cs to decorate quantities with new behavior.
// Add UnitDefinitions\MyQuantity.json and run GeneratUnits.bat to generate new units or quantities.
//
// </auto-generated>
//------------------------------------------------------------------------------

// Copyright (c) 2013 Andreas Gullberg Larsen ([email protected]).
// https://github.com/angularsen/UnitsNet
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.


using System;
using Xunit;

namespace UnitsNet.Tests.CustomCode
{
public class HeatFluxTests : HeatFluxTestsBase
{
protected override double BtusPerHourSquareFootInOneWattPerSquareMeter => 3.16998331e-1;
protected override double BtusPerMinuteSquareFootInOneWattPerSquareMeter => 5.28330551e-3;
protected override double BtusPerSecondSquareFootInOneWattPerSquareMeter => 8.80550918e-5;
protected override double BtusPerSecondSquareInchInOneWattPerSquareMeter => 6.11493693e-7;
protected override double CaloriesPerSecondSquareCentimeterInOneWattPerSquareMeter => 2.388458966e-5;
protected override double CentiwattsPerSquareMeterInOneWattPerSquareMeter => 1e2;
protected override double DeciwattsPerSquareMeterInOneWattPerSquareMeter => 1e1;
protected override double KilocaloriesPerSecondSquareCentimeterInOneWattPerSquareMeter => 2.388458966e-8;
protected override double KilocaloriesPerHourSquareMeterInOneWattPerSquareMeter => 8.59845227859e-1;
protected override double KilowattsPerSquareMeterInOneWattPerSquareMeter => 1e-3;
protected override double MicrowattsPerSquareMeterInOneWattPerSquareMeter => 1e6;
protected override double MilliwattsPerSquareMeterInOneWattPerSquareMeter => 1e3;
protected override double NanowattsPerSquareMeterInOneWattPerSquareMeter => 1e9;
protected override double WattsPerSquareFootInOneWattPerSquareMeter => 9.290304e-2;
protected override double WattsPerSquareInchInOneWattPerSquareMeter => 6.4516e-4;
protected override double WattsPerSquareMeterInOneWattPerSquareMeter => 1;

[Fact]
public void PowerDividedByAreaEqualsHeatFlux()
{
HeatFlux heatFlux = Power.FromWatts(12) / Area.FromSquareMeters(3);
Assert.Equal(heatFlux, HeatFlux.FromWattsPerSquareMeter(4));
}

[Fact]
public void HeatFluxTimesAreaEqualsPower()
{
Power power = HeatFlux.FromWattsPerSquareMeter(3) * Area.FromSquareMeters(4);
Assert.Equal(power, Power.FromWatts(12));
}

[Fact]
public void PowerDividedByHeatFluxEqualsArea()
{
Area area = Power.FromWatts(12) / HeatFlux.FromWattsPerSquareMeter(3);
Assert.Equal(area, Area.FromSquareMeters(4));
}
}
}
Loading