Beispiel #1
0
            given_object_and_output_parameter_and_expression_when_storing_should_take_value_from_expression_and_store_in_output_parameter
            ()
        {
            var value = new Person { FirstName = "Todd", LastName = "Meinershagen" };
            string output;

            value.Store(out output, x => x.LastName);

            output.Should().Be(value.LastName);
        }
        public void given_value_and_message_when_printing_to_debug_should_write_message_to_console()
        {
            var builder = new StringBuilder();
            using (var writer = new StringWriter(builder))
            {
                Console.SetOut(writer);
                var value = new Person { FirstName = "Todd", LastName = "Meinershagen" };

                var result = value.DebugPrint("This is a message.");
                result.Should().Be(value);
            }

            builder.ToString().Should().Be("This is a message.\r\n");
        }
        public void given_value_and_function_for_getting_an_object_when_printing_to_debug_should_write_property_value_to_console()
        {
            var builder = new StringBuilder();
            using (var writer = new StringWriter(builder))
            {
                Console.SetOut(writer);
                var value = new Person {FirstName = "Todd", LastName = "Meinershagen"};

                var result = value.DebugPrint(x => x.LastName);
                result.Should().Be(value);
            }

            builder.ToString().Should().Be("Meinershagen\r\n");
        }