public void Default_formatter_for_null_Nullable_indicates_null() { var formatter = new FormatterSet(); int?nullable = null; var output = formatter.Format(nullable); Assert.That(output, Is.EqualTo(formatter.Format <object>(null))); }
public void Default_formatter_for_Type_displays_only_the_name() { var formatter = new FormatterSet(); Assert.That(formatter.Format(GetType()), Is.EqualTo(GetType().Name)); Assert.That(formatter.Format(typeof(FormatterSetTests)), Is.EqualTo(typeof(FormatterSetTests).Name)); }
public void Exceptions_always_get_properties_formatters() { var exception = new ReflectionTypeLoadException( new[] { typeof(FileStyleUriParser), typeof(AssemblyKeyFileAttribute) }, new Exception[] { new EventLogInvalidDataException() }); var formatter = new FormatterSet(); var message = formatter.Format(exception); Assert.That(message, Contains.Substring("ReflectionTypeLoadException")); Assert.That(message, Contains.Substring("FileStyleUriParser")); Assert.That(message, Contains.Substring("AssemblyKeyFileAttribute")); Assert.That(message, Contains.Substring("EventLogInvalidDataException")); }
public void When_Clear_is_called_then_default_formatters_are_immediately_reregistered() { var formatterSet = new FormatterSet(); var logEntry = new LogEntry("hola!"); var before = formatterSet.Format(logEntry); formatterSet.RegisterFormatter <LogEntry>(e => "hello!"); Assert.That(formatterSet.Format(logEntry), Is.Not.EqualTo(before)); formatterSet.Clear(); Assert.That(formatterSet.Format(logEntry), Is.EqualTo(before)); }
public void Anonymous_types_are_automatically_fully_formatted() { var formatter = new FormatterSet(); var ints = new[] { 3, 2, 1 }; var output = formatter.Format(new { ints, count = ints.Count() }); Assert.That(output, Is.EqualTo("{ ints = { 3, 2, 1 } | count = 3 }")); }
public void RegisterPropertiesFormatter_for_string_does_nothing() { var formatter = new FormatterSet(); formatter.RegisterPropertiesFormatter <string>(); Assert.That(formatter.Format("hello"), Is.EqualTo("hello")); }
public void Custom_formatter_for_Type_can_be_registered() { var formatter = new FormatterSet(); formatter.RegisterFormatter <Type>(t => t.GUID.ToString()); Assert.That(formatter.Format(GetType()), Is.EqualTo(GetType().GUID.ToString())); }
public void Static_properties_are_not_written() { var formatter = new FormatterSet(); formatter.RegisterPropertiesFormatter <BoundaryTests.NestedWidget>(); Assert.That(formatter.Format(new Widget()), !Contains.Substring("StaticProperty")); }
public void FormatterSet_truncates_expansion_of_long_IEnumerable() { var list = new List <string>(); for (var i = 1; i < 11; i++) { list.Add("number " + i); } var formatterSet = new FormatterSet { ListExpansionLimit = 4 }; var formatted = formatterSet.Format(list); Console.WriteLine(formatted); Assert.IsTrue(formatted.Contains("number 1")); Assert.IsTrue(formatted.Contains("number 4")); Assert.IsFalse(formatted.Contains("number 5")); Assert.IsTrue(formatted.Contains("6 more")); }
public void RegisterPropertiesFormatter_for_string_does_nothing() { var formatter = new FormatterSet(); formatter.RegisterPropertiesFormatter<string>(); Assert.That(formatter.Format("hello"), Is.EqualTo("hello")); }
public void Custom_formatter_for_Type_can_be_registered() { var formatter = new FormatterSet(); formatter.RegisterFormatter<Type>(t => t.GUID.ToString()); Assert.That(formatter.Format(GetType()), Is.EqualTo(GetType().GUID.ToString())); }
public void Default_formatter_for_null_Nullable_indicates_null() { var formatter = new FormatterSet(); int? nullable = null; var output = formatter.Format(nullable); Assert.That(output, Is.EqualTo(formatter.Format<object>(null))); }
public void FormatterSet_truncates_expansion_of_long_IEnumerable() { var list = new List<string>(); for (var i = 1; i < 11; i++) { list.Add("number " + i); } var formatterSet = new FormatterSet { ListExpansionLimit = 4 }; var formatted = formatterSet.Format(list); Console.WriteLine(formatted); Assert.IsTrue(formatted.Contains("number 1")); Assert.IsTrue(formatted.Contains("number 4")); Assert.IsFalse(formatted.Contains("number 5")); Assert.IsTrue(formatted.Contains("6 more")); }
public void Static_properties_are_not_written() { var formatter = new FormatterSet(); formatter.RegisterPropertiesFormatter<BoundaryTests.NestedWidget>(); Assert.That(formatter.Format(new Widget()), !Contains.Substring("StaticProperty")); }
public void Default_formatter_for_Type_displays_only_the_name() { var formatter = new FormatterSet(); Assert.That(formatter.Format(GetType()), Is.EqualTo(GetType().Name)); Assert.That(formatter.Format(typeof (FormatterSetTests)), Is.EqualTo(typeof (FormatterSetTests).Name)); }
public void When_Clear_is_called_then_default_formatters_are_immediately_reregistered() { var formatterSet = new FormatterSet(); var logEntry = new LogEntry("hola!"); var before = formatterSet.Format(logEntry); formatterSet.RegisterFormatter<LogEntry>(e => "hello!"); Assert.That(formatterSet.Format(logEntry), Is.Not.EqualTo(before)); formatterSet.Clear(); Assert.That(formatterSet.Format(logEntry), Is.EqualTo(before)); }
public void Exceptions_always_get_properties_formatters() { var exception = new ReflectionTypeLoadException( new[] { typeof (FileStyleUriParser), typeof (AssemblyKeyFileAttribute) }, new Exception[] { new EventLogInvalidDataException() }); var formatter = new FormatterSet(); var message = formatter.Format(exception); Assert.That(message, Contains.Substring("ReflectionTypeLoadException")); Assert.That(message, Contains.Substring("FileStyleUriParser")); Assert.That(message, Contains.Substring("AssemblyKeyFileAttribute")); Assert.That(message, Contains.Substring("EventLogInvalidDataException")); }