public void CreateForMembers_throws_when_an_expression_is_not_a_MemberExpression() { var ex = Assert.Throws <ArgumentException>(() => PlainTextFormatter <SomethingWithLotsOfProperties> .CreateForMembers( o => o.DateProperty.ToShortDateString(), o => o.StringProperty)); ex.Message.Should().Contain("o => o.DateProperty.ToShortDateString()"); }
public void CreateForMembers_emits_the_specified_property_names_and_values_for_a_specific_type() { var formatter = PlainTextFormatter <SomethingWithLotsOfProperties> .CreateForMembers( o => o.DateProperty, o => o.StringProperty); var s = new SomethingWithLotsOfProperties { DateProperty = DateTime.MinValue, StringProperty = "howdy" }.ToDisplayString(formatter); s.Should().Contain("DateProperty: 0001-01-01 00:00:00Z"); s.Should().Contain("StringProperty: howdy"); s.Should().NotContain("IntProperty"); s.Should().NotContain("BoolProperty"); s.Should().NotContain("UriProperty"); }