-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from WildernessLabs/v1.11.0
V1.11.0
- Loading branch information
Showing
48 changed files
with
1,470 additions
and
996 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using Xunit; | ||
|
||
namespace Meadow.Units.Tests; | ||
|
||
public class DigitalStorageTests | ||
{ | ||
[Fact] | ||
public void DigitalStorageOneByteConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.Bytes); | ||
Assert.True(one.Bytes == 1); | ||
} | ||
|
||
[Fact] | ||
public void DigitalStorageOneKBConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.KiloBytes); | ||
Assert.True(one.Bytes == 1000); | ||
Assert.True(one.Bits == one.Bytes * 8); | ||
|
||
var oneA = new DigitalStorage(1000, DigitalStorage.UnitType.Bytes); | ||
Assert.True(oneA.KiloBytes == 1); | ||
} | ||
|
||
[Fact] | ||
public void DigitalStorageOneKiBConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.KibiBytes); | ||
Assert.True(one.Bytes == 1024); | ||
Assert.True(one.Bits == one.Bytes * 8); | ||
|
||
var oneA = new DigitalStorage(1024, DigitalStorage.UnitType.Bytes); | ||
Assert.True(oneA.KibiBytes == 1); | ||
Assert.True(oneA.Kibibits == 0.125); | ||
} | ||
|
||
[Fact] | ||
public void DigitalStorageOneMBConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.MegaBytes); | ||
Assert.True(one.Bytes == 1000_000); | ||
Assert.True(one.Bits == one.Bytes * 8); | ||
|
||
var oneA = new DigitalStorage(1000_000, DigitalStorage.UnitType.Bytes); | ||
Assert.True(oneA.MegaBytes == 1); | ||
} | ||
|
||
[Fact] | ||
public void DigitalStorageOneMiBConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.MebiBytes); | ||
Assert.True(one.Bytes == 1024 * 1024); | ||
Assert.True(one.Bits == one.Bytes * 8); | ||
|
||
var oneA = new DigitalStorage(1024 * 1024, DigitalStorage.UnitType.Bytes); | ||
Assert.True(oneA.MebiBytes == 1); | ||
Assert.True(oneA.Mebibits == 0.125); | ||
} | ||
|
||
[Fact] | ||
public void DigitalStorageOneGBConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.GigaBytes); | ||
Assert.True(one.Bytes == 1000_000_000); | ||
Assert.True(one.Bits == one.Bytes * 8); | ||
} | ||
|
||
[Fact] | ||
public void DigitalStorageOneGiBConstructor() | ||
{ | ||
var one = new DigitalStorage(1, DigitalStorage.UnitType.GibiBytes); | ||
Assert.True(one.Bytes == 1024 * 1024 * 1024); | ||
Assert.True(one.Bits == one.Bytes * 8); | ||
|
||
var oneA = new DigitalStorage(1024 * 1024 * 1024, DigitalStorage.UnitType.Bytes); | ||
Assert.True(oneA.GibiBytes == 1); | ||
} | ||
|
||
[Fact] | ||
public void Subtraction() | ||
{ | ||
var total = new DigitalStorage(30431968, DigitalStorage.UnitType.KibiBytes); | ||
var available = new DigitalStorage(25975940, DigitalStorage.UnitType.KibiBytes); | ||
var inUse = new DigitalStorage(4456028, DigitalStorage.UnitType.KibiBytes); | ||
|
||
var testAvailable = total - inUse; | ||
Assert.Equal(available.Bytes, testAvailable.Bytes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,69 @@ | ||
using Xunit; | ||
using System; | ||
using Meadow.Units; | ||
using MU = Meadow.Units.Mass.UnitType; | ||
|
||
namespace Meadow.Units.Tests | ||
namespace Meadow.Units.Tests; | ||
|
||
public class MassTests | ||
{ | ||
public class MassTests | ||
[Fact()] | ||
public void MassCtors() | ||
{ | ||
[Fact()] | ||
public void MassCtors() | ||
{ | ||
Mass t = new Mass(100, MU.Grams); | ||
Assert.True(t.Grams == 100); | ||
Mass t = new Mass(100, MU.Grams); | ||
Assert.True(t.Grams == 100); | ||
|
||
Mass t2 = new Mass(); | ||
Assert.True(t2.Grams == 0); | ||
} | ||
Mass t2 = new Mass(); | ||
Assert.True(t2.Grams == 0); | ||
} | ||
|
||
[Fact()] | ||
public void MassConversions() | ||
{ | ||
Mass t = new Mass(1000, MU.Grams); | ||
Assert.True(t.Kilograms.Equals3DigitPrecision(1)); | ||
Assert.True(t.Ounces.Equals4DigitPrecision(35.274)); | ||
Assert.True(t.Pounds.Equals4DigitPrecision(2.20462)); | ||
Assert.True(t.TonsMetric.Equals4DigitPrecision(0.001)); | ||
Assert.True(t.TonsUSShort.Equals4DigitPrecision(0.00110231)); | ||
Assert.True(t.TonsUKLong.Equals4DigitPrecision(0.000984207)); | ||
Assert.True(t.Grains.Equals4DigitPrecision(15432.3584)); | ||
Assert.True(t.Karats.Equals4DigitPrecision(5000)); | ||
[Fact()] | ||
public void MassConversions() | ||
{ | ||
Mass t = new Mass(1000, MU.Grams); | ||
Assert.True(t.Kilograms.Equals3DigitPrecision(1)); | ||
Assert.True(t.Ounces.Equals4DigitPrecision(35.274)); | ||
Assert.True(t.Pounds.Equals4DigitPrecision(2.20462)); | ||
Assert.True(t.TonsMetric.Equals4DigitPrecision(0.001)); | ||
Assert.True(t.TonsUSShort.Equals4DigitPrecision(0.00110231)); | ||
Assert.True(t.TonsUKLong.Equals4DigitPrecision(0.000984207)); | ||
Assert.True(t.Grains.Equals4DigitPrecision(15432.3584)); | ||
Assert.True(t.Karats.Equals4DigitPrecision(5000)); | ||
|
||
|
||
Mass t2 = new Mass(10, MU.Pounds); | ||
Assert.True(t2.Kilograms.Equals4DigitPrecision(4.53592)); | ||
Mass t2 = new Mass(10, MU.Pounds); | ||
Assert.True(t2.Kilograms.Equals4DigitPrecision(4.53592)); | ||
|
||
Mass t3 = new Mass(50, MU.Grains); | ||
Assert.True(t3.Grams.Equals4DigitPrecision(3.23995)); | ||
} | ||
Mass t3 = new Mass(50, MU.Grains); | ||
Assert.True(t3.Grams.Equals4DigitPrecision(3.23995)); | ||
} | ||
|
||
[Fact()] | ||
public void MassMathOps() | ||
{ | ||
Mass t1 = new Mass(1, MU.Kilograms); | ||
Mass t2 = new Mass(10, MU.Kilograms); | ||
Mass t3 = new Mass(-3, MU.Kilograms); | ||
Assert.True(t1 != t2); | ||
Assert.True((t1 + t2) == new Mass(11, MU.Kilograms)); | ||
Assert.True((t2 - t1) == new Mass(9, MU.Kilograms)); | ||
[Fact()] | ||
public void MassMathOps() | ||
{ | ||
Mass t1 = new Mass(1, MU.Kilograms); | ||
Mass t2 = new Mass(10, MU.Kilograms); | ||
Mass t3 = new Mass(-3, MU.Kilograms); | ||
Assert.True(t1 != t2); | ||
Assert.True((t1 + t2) == new Mass(11, MU.Kilograms)); | ||
Assert.True((t2 - t1) == new Mass(9, MU.Kilograms)); | ||
|
||
Assert.True(t3.Abs() == new Mass(3, MU.Kilograms)); | ||
} | ||
Assert.True(t3.Abs() == new Mass(3, MU.Kilograms)); | ||
} | ||
|
||
[Fact()] | ||
public void MassComparisons() | ||
{ | ||
Mass t1 = new Mass(1); | ||
Mass t2 = new Mass(10); | ||
Mass t3 = new Mass(10); | ||
[Fact()] | ||
public void MassComparisons() | ||
{ | ||
Mass t1 = new Mass(1); | ||
Mass t2 = new Mass(10); | ||
Mass t3 = new Mass(10); | ||
|
||
Assert.True(t1 < t2); | ||
Assert.True(t2 <= t3); | ||
Assert.True(t2 > t1); | ||
Assert.True(t3 >= t2); | ||
Assert.True(t1 < t2); | ||
Assert.True(t2 <= t3); | ||
Assert.True(t2 > t1); | ||
Assert.True(t3 >= t2); | ||
|
||
Assert.True(t2 == t3); | ||
Assert.True(t2 == t3); | ||
|
||
Assert.True(t2 == new Mass(10, MU.Grams)); | ||
Assert.True(t2 > new Mass(5, MU.Grams)); | ||
} | ||
Assert.True(t2 == new Mass(10, MU.Grams)); | ||
Assert.True(t2 > new Mass(5, MU.Grams)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
namespace Meadow.Units | ||
namespace Meadow.Units | ||
{ | ||
/// <summary> | ||
/// Cardinal compass directions | ||
|
Oops, something went wrong.