using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnitTestSharp; using Core.Substances; namespace CoreTests.Substances { public class SubstanceTest : TestFixture { public void TestSubtractsProper() { Substance a = 10; Substance b = 5; Substance amb = 5; Substance bma = 0; CheckEqual(a - b, amb); CheckEqual(b - a, bma); a = -10; b = -5; amb = 0; bma = 5; CheckEqual(a - b, amb); CheckEqual(b - a, bma); a = 10; b = -5; amb = 15; bma = 0; CheckEqual(a - b, amb); CheckEqual(b - a, bma); } public void TestAddsProper() { Substance a = 10; Substance b = 5; Substance apb = 15; Substance bpa = 15; CheckEqual(a + b, apb); CheckEqual(b + a, bpa); a = -10; b = -5; apb = 0; bpa = 0; CheckEqual(a + b, apb); CheckEqual(b + a, bpa); a = 10; b = -5; apb = 5; bpa = 5; CheckEqual(a + b, apb); CheckEqual(b + a, bpa); } public void TestNeverEstimatesAndMultipliesProper() { CheckFalse(1.1 * 0.1 == 0.11); Substance a = new Substance(new Decimal(1.1)); Substance b = new Substance(new Decimal(0.1)); Substance c = new Substance(new Decimal(0.11)); CheckTrue(a * b == c); CheckTrue(b * a == c); } } }