public void TestFactorOfOne() { List <int> factors = SuperMath.GetFactors(1); Assert.AreEqual(1, factors.Count); Assert.AreEqual(1, factors[0]); }
private void tbxNumber_TextChanged(object sender, TextChangedEventArgs e) { if (tbFactors == null) { return; } if (int.TryParse(tbxNumber.Text, out int result)) { tbFactors.Text = $"{string.Join(", ", SuperMath.GetFactors(result))}"; } else { tbFactors.Text = ""; } }
public void TestGetFactors() { List <int> factors = SuperMath.GetFactors(6); Assert.AreEqual(2, factors.Count); Assert.AreEqual(2, factors[0]); Assert.AreEqual(3, factors[1]); factors = SuperMath.GetFactors(10); Assert.AreEqual(2, factors.Count); Assert.AreEqual(2, factors[0]); Assert.AreEqual(5, factors[1]); factors = SuperMath.GetFactors(9); Assert.AreEqual(2, factors.Count); Assert.AreEqual(2, factors.FindAll(x => x == 3).Count); factors = SuperMath.GetFactors(8); Assert.AreEqual(3, factors.Count); Assert.AreEqual(3, factors.FindAll(x => x == 2).Count); }