public void FromStandardShouldTriviallyHandleZeroC() { var pair = NextRelativelyPrimePair(this.random); var factored = Factored.FromStandard(new Standard(pair.Item1, pair.Item2, 0)); Assert.Equal(1, factored.D); Assert.Equal(1, factored.E); Assert.Equal(0, factored.H); Assert.Equal(pair.Item1, factored.F); Assert.Equal(pair.Item2, factored.G); }
public void EqualsShouldReturnTrueForIdenticalInstance() { var clone = new Factored( this.defaultFactored.D, this.defaultFactored.E, this.defaultFactored.H, this.defaultFactored.F, this.defaultFactored.G); Assert.True(this.defaultFactored.Equals((object)clone)); }
public void FromStandardShouldFactorCorrectly() { /* * 5(4x - 3)(2x + 1) * 5 * [(4 * 2)x² + (4 * 1)x + (-3 * 2)x + (-3 * 1)] * 5 * [8x² + 4x - 6x - 3] * 40x² - 10x - 15 */ var factored = Factored.FromStandard(new Standard(40, -10, -15)); Assert.Equal(new Factored(5, 4, -3, 2, 1), factored); }
public void EqualsShouldReturnFalseForDifferentInstances() { var pair = NextRelativelyPrimePair(this.random); var notClone = new Factored( this.defaultFactored.D, this.defaultFactored.E, this.defaultFactored.H, pair.Item1, pair.Item2); Assert.False(this.defaultFactored.Equals((object)notClone)); }
public void ConstructorShouldCleanUpPairs() { var eh = NextRelativelyPrimePair(this.random); long e = eh.Item1; long h = eh.Item2; var fg = NextRelativelyPrimePair(this.random); long f = fg.Item1; long g = fg.Item2; var equation = new Factored(1, e * 2, h * 2, f * 3, g * 3); Assert.Equal(6, equation.D); Assert.Equal(e, equation.E); Assert.Equal(f, equation.F); Assert.Equal(g, equation.G); Assert.Equal(h, equation.H); }
public void ConstructorShouldMapValuesCorrectly() { var d = this.random.NextNonZeroInt64(); var eh = NextRelativelyPrimePair(this.random); var e = eh.Item1; var h = eh.Item2; var fg = NextRelativelyPrimePair(this.random); var f = fg.Item1; var g = fg.Item2; var equation = new Factored(d, e, h, f, g); Assert.Equal(d, equation.D); Assert.Equal(e, equation.E); Assert.Equal(f, equation.F); Assert.Equal(g, equation.G); Assert.Equal(h, equation.H); }
public void FromStandardShouldReturnNullForUnfactorableEquation() { var factored = Factored.FromStandard(new Standard(1, 2, 3)); Assert.Null(factored); }
public void FromStandardShouldErrorOnNull() { Assert.Throws <ArgumentNullException>(() => Factored.FromStandard(null)); }
public void ToStringShouldHandleSquares() { var factored = new Factored(-2, 1, 0, 1, 0); Assert.Equal("-2x²", factored.ToString()); }
public FactoredTests() { this.random = new Random(); this.defaultFactored = NextFactored(this.random); }
public void ToStringShouldWork() { var factored = new Factored(2, -3, 4, 5, -6); Assert.Equal("2(-3x + 4)(5x - 6)", factored.ToString()); }
public void ToFactoredShouldBeTheSameAsFactoredFromStandard(long a, long b, long c) { var standard = new Standard(a, b, c); Assert.Equal(Factored.FromStandard(standard), standard.ToFactored()); }