public void Invalidly_formatted_strings_throw_exception(string propertyName, string serializedValue) { var exampleObject = new PropertyInfoExtensionsTestClass(); var propertyInfo = typeof(PropertyInfoExtensionsTestClass) .GetProperties() .First(p => p.Name == propertyName); propertyInfo.Invoking(p => p.SetProperty(serializedValue, exampleObject)) .Should() .Throw <Exception>(); }
public void Validly_formatted_strings_are_cast_and_added_to_the_object(string propertyName, string serializedValue, string expectedStringValue) { var exampleObject = new PropertyInfoExtensionsTestClass(); var propertyInfo = typeof(PropertyInfoExtensionsTestClass) .GetProperties() .First(p => p.Name == propertyName); propertyInfo.SetProperty(serializedValue, exampleObject); var output = propertyInfo.GetValue(exampleObject).ToString(); output.Should().Be(expectedStringValue); }