public void When_no_custom_formatter_exists_in_the_specified_assembly_it_should_use_the_default() { // Arrange Configuration.Current.ValueFormatterAssembly = "FluentAssertions"; var subject = new SomeClassWithCustomFormatter { Property = "SomeValue" }; // Act string result = Formatter.ToString(subject); // Assert result.Should().Be(subject.ToString()); }
public void When_formatter_scanning_is_disabled_it_should_use_the_default_formatters() { // Arrange Configuration.Current.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Disabled; var subject = new SomeClassWithCustomFormatter { Property = "SomeValue" }; // Act string result = Formatter.ToString(subject); // Assert result.Should().Be(subject.ToString()); }
public void When_a_custom_formatter_exists_in_any_loaded_assembly_it_should_override_the_default_formatters() { // Arrange Configuration.Current.ValueFormatterDetectionMode = ValueFormatterDetectionMode.Scan; var subject = new SomeClassWithCustomFormatter { Property = "SomeValue" }; // Act string result = Formatter.ToString(subject); // Assert result.Should().Be("Property = SomeValue", "it should use my custom formatter"); }
public void When_a_custom_formatter_exists_in_the_current_assembly_it_should_override_the_default_formatters() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- var subject = new SomeClassWithCustomFormatter { Property = "SomeValue" }; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- string result = Formatter.ToString(subject); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.Should().Be("Property = SomeValue"); }
public void When_no_formatter_scanning_is_configured_it_should_use_the_default_formatters() { //----------------------------------------------------------------------------------------------------------- // Arrange //----------------------------------------------------------------------------------------------------------- Services.ResetToDefaults(); var subject = new SomeClassWithCustomFormatter { Property = "SomeValue" }; //----------------------------------------------------------------------------------------------------------- // Act //----------------------------------------------------------------------------------------------------------- string result = Formatter.ToString(subject); //----------------------------------------------------------------------------------------------------------- // Assert //----------------------------------------------------------------------------------------------------------- result.Should().Be(subject.ToString()); }
public static string Foo(SomeClassWithCustomFormatter value) { return("Property = " + value.Property); }
public static string Foo(SomeClassWithCustomFormatter value) { return "Property = " + value.Property; }
public static void Foo(SomeClassWithCustomFormatter value, FormattedObjectGraph output) { output.AddFragment("Property = " + value.Property); }
public static int Bar(SomeClassWithCustomFormatter _) { return(-1); }