public void Given_Property_When_DefaultJsonProperyAnnotation_Invoked_Then_It_Should_Return_ElementName() { var name = "FakePropertyNoAnnotation"; var property = typeof(FakeModel).GetProperty(name, BindingFlags.Public | BindingFlags.Instance); var namingStrategy = new DefaultNamingStrategy(); var result = PropertyInfoExtensions.GetJsonPropertyName(property, namingStrategy); result.Should().NotBeNullOrEmpty(); result.Should().Be(name); }
public void Given_Property_When_GetJsonPropertyName_Invoked_Then_It_Should_Return_JsonPropertyName() { var name = "FakeProperty2"; var jsonPropertyName = "anotherFakeProperty"; var property = typeof(FakeModel).GetProperty(name, BindingFlags.Public | BindingFlags.Instance); var namingStrategy = new DefaultNamingStrategy(); var result = PropertyInfoExtensions.GetJsonPropertyName(property, namingStrategy); result.Should().Be(jsonPropertyName); }
public void Given_Property_When_GetJsonPropertyName_IsEmpty_WithCamelCaseNaming_Then_It_Should_Return_ElementName() { var name = "FakePropertyNoPropertyValue"; var camelCaseName = "fakePropertyNoPropertyValue"; var property = typeof(FakeModel).GetProperty(name, BindingFlags.Public | BindingFlags.Instance); var namingStrategy = new CamelCaseNamingStrategy(); var result = PropertyInfoExtensions.GetJsonPropertyName(property, namingStrategy); result.Should().NotBeNullOrEmpty(); result.Should().Be(camelCaseName); }