public void ToString_uses_formatter_service(IFormatsFraction formatter, Fraction sut, string expected) { Fraction.Formatter = formatter; Mock.Get(formatter).Setup(x => x.Format(sut, "S")).Returns(expected); Assert.That(() => sut.ToString(), Is.EqualTo(expected)); }
/// <summary> /// Resets the internal services which are used by the <see cref="Fraction"/> class for /// parsing, simplification and formatting. /// </summary> internal static void ResetServices() { Parser = new FractionParser(); Simplifier = new FractionSimplifier(); Formatter = new FractionFormatter(Simplifier); }
public void ToString_formattable_uses_a_formatter_if_it_is_the_correct_interface(IFormatsFraction formatter, IFormatProvider provider, Fraction sut, string format, string expected) { Mock.Get(provider).Setup(x => x.GetFormat(typeof(IFormatsFraction))).Returns(formatter); Mock.Get(formatter).Setup(x => x.Format(sut, format)).Returns(expected); Assert.That(() => sut.ToString(format, provider), Is.EqualTo(expected)); }