public static void FormatValue_DecimalIsWrittenWithTrailingM() { Assert.That(MsgUtils.FormatValue(0.5m), Is.EqualTo("0.5m")); }
public static void FormatValue_DecimalIsWrittenToTwentyNineDigits() { Assert.That(MsgUtils.FormatValue(12345678901234567890123456789m), Is.EqualTo("12345678901234567890123456789m")); }
public static void FormatValue_FloatIsWrittenWithTrailingF() { Assert.That(MsgUtils.FormatValue(0.5f), Is.EqualTo("0.5f")); }
public static void FormatValue_DoubleIsWrittenToSeventeenDigits() { string s = MsgUtils.FormatValue(0.33333333333333333333333333333333333333333333d); Assert.That(s.Length, Is.EqualTo(20)); // add 3 for leading 0, decimal and trailing d }
public static void FormatValue_IntegerIsWrittenAsIs() { Assert.That(MsgUtils.FormatValue(42), Is.EqualTo("42")); }
public static void FormatValue_TwoElementsValueTupleTest() { string s = MsgUtils.FormatValue(ValueTuple.Create("Hello", 123)); Assert.That(s, Is.EqualTo("(\"Hello\", 123)")); }
public static void FormatValue_KeyValuePairTest(object key, object value, string expectedResult) { string s = MsgUtils.FormatValue(new KeyValuePair <object, object>(key, value)); Assert.That(s, Is.EqualTo(expectedResult)); }
public static void FormatValue_ContextualCustomFormatterInvoked_FactoryArg() { TestContext.AddFormatter(next => val => (val is CustomFormattableType) ? "custom_formatted" : next(val)); Assert.That(MsgUtils.FormatValue(new CustomFormattableType()), Is.EqualTo("custom_formatted")); }
public static void FormatValue_DoubleIsWrittenWithTrailingD() { Assert.That(MsgUtils.FormatValue(0.5d), Is.EqualTo("0.5d")); }
public static void FormatValue_CharTest(char c, string expected) { Assert.That(MsgUtils.FormatValue(c), Is.EqualTo(expected)); }
public void PercentTolerance_Failure(object actual, object expected, object tolerance) { var ex = Assert.Throws <AssertionException>( () => Assert.That(actual, Is.GreaterThanOrEqualTo(expected).Within(tolerance).Percent), "Assertion should have failed"); Assert.That(ex.Message, Contains.Substring("Expected: greater than or equal to " + MsgUtils.FormatValue(expected) + " within " + MsgUtils.FormatValue(tolerance) + " percent")); }
public void SimpleTolerance_Failure(object actual, object expected, object tolerance) { var ex = Assert.Throws <AssertionException>( () => Assert.That(actual, Is.LessThan(expected).Within(tolerance)), "Assertion should have failed"); Assert.That(ex.Message, Contains.Substring("Expected: less than " + MsgUtils.FormatValue(expected) + " within " + MsgUtils.FormatValue(tolerance))); }
#pragma warning restore IDE1006 /// <summary> /// Construct a TypeConstraint for a given Type /// </summary> /// <param name="type">The expected type for the constraint</param> /// <param name="descriptionPrefix">Prefix used in forming the constraint description</param> protected TypeConstraint(Type type, string descriptionPrefix) : base(type) { this.expectedType = type; this.Description = descriptionPrefix + MsgUtils.FormatValue(expectedType); }
public static void FormatValue_DateTimeTest() { Assert.That(MsgUtils.FormatValue(new DateTime(2007, 7, 4, 9, 15, 30, 123)), Is.EqualTo("2007-07-04 09:15:30.123")); }
public static void FormatValue_EmptyValueTupleTest() { string s = MsgUtils.FormatValue(ValueTuple.Create()); Assert.That(s, Is.EqualTo("()")); }
public static void FormatValue_DateTimeOffsetTest() { Assert.That(MsgUtils.FormatValue(new DateTimeOffset(2007, 7, 4, 9, 15, 30, 123, TimeSpan.FromHours(8))), Is.EqualTo("2007-07-04 09:15:30.123+08:00")); }
public static void FormatValue_OneElementTupleTest() { string s = MsgUtils.FormatValue(Tuple.Create("Hello")); Assert.That(s, Is.EqualTo("(\"Hello\")")); }
public static void FormatValue_ContextualCustomFormatterInvoked_FormatterArg() { TestContext.AddFormatter <CustomFormattableType>(val => "custom_formatted_using_type"); Assert.That(MsgUtils.FormatValue(new CustomFormattableType()), Is.EqualTo("custom_formatted_using_type")); }
public static void FormatValue_ThreeElementsTupleTest() { string s = MsgUtils.FormatValue(Tuple.Create("Hello", 123, 'a')); Assert.That(s, Is.EqualTo("(\"Hello\", 123, 'a')")); }
public static void FormatValue_StringIsWrittenWithQuotes() { Assert.That(MsgUtils.FormatValue("Hello"), Is.EqualTo("\"Hello\"")); }
public static void FormatValue_DirectoryEntryTest(object key, object value, string expectedResult) { string s = MsgUtils.FormatValue(new DictionaryEntry(key, value)); Assert.That(s, Is.EqualTo(expectedResult)); }