コード例 #1
0
        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());
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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");
        }
コード例 #4
0
        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_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");
        }
コード例 #6
0
        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());
        }
コード例 #7
0
 public static string Foo(SomeClassWithCustomFormatter value)
 {
     return("Property = " + value.Property);
 }
 public static string Foo(SomeClassWithCustomFormatter value)
 {
     return "Property = " + value.Property;
 }
コード例 #9
0
 public static void Foo(SomeClassWithCustomFormatter value, FormattedObjectGraph output)
 {
     output.AddFragment("Property = " + value.Property);
 }
コード例 #10
0
 public static int Bar(SomeClassWithCustomFormatter _)
 {
     return(-1);
 }