Remove unecessary duplicate of API

This commit is contained in:
Daniel Cronqvist 2024-08-31 19:59:20 +02:00
parent ce3d4e339c
commit 4e273cd521
2 changed files with 6 additions and 21 deletions

View file

@ -36,7 +36,7 @@ public class HasPropertiesBaseTests
var hasProperties = new TestHasProperties(props);
// Act & Assert
_ = Assert.Throws<KeyNotFoundException>(() => hasProperties.MapClassPropertyTo<MapTo>("ClassInObject"));
_ = Assert.Throws<KeyNotFoundException>(() => hasProperties.GetProperty<ClassProperty>("ClassInObject").MapPropertiesTo<MapTo>());
}
[Fact]
@ -49,7 +49,7 @@ public class HasPropertiesBaseTests
var hasProperties = new TestHasProperties(props);
// Act & Assert
_ = Assert.Throws<InvalidCastException>(() => hasProperties.MapClassPropertyTo<MapTo>("ClassInObject"));
_ = Assert.Throws<InvalidCastException>(() => hasProperties.GetProperty<ClassProperty>("ClassInObject").MapPropertiesTo<MapTo>());
}
[Fact]
@ -74,7 +74,7 @@ public class HasPropertiesBaseTests
var hasProperties = new TestHasProperties(props);
// Act
var mappedProperty = hasProperties.MapClassPropertyTo<MapTo>("ClassInObject");
var mappedProperty = hasProperties.GetProperty<ClassProperty>("ClassInObject").MapPropertiesTo<MapTo>();
// Assert
Assert.True(mappedProperty.MapToBool);
@ -121,7 +121,7 @@ public class HasPropertiesBaseTests
var hasProperties = new TestHasProperties(props);
// Act
var mappedProperty = hasProperties.MapClassPropertyTo<NestedMapTo>("ClassInObject");
var mappedProperty = hasProperties.GetProperty<ClassProperty>("ClassInObject").MapPropertiesTo<NestedMapTo>();
// Assert
Assert.Equal("Test", mappedProperty.NestedMapToString);
@ -162,7 +162,7 @@ public class HasPropertiesBaseTests
var hasProperties = new TestHasProperties(props);
// Act
var mappedProperty = hasProperties.MapClassPropertyTo<EnumMapTo>("ClassInObject");
var mappedProperty = hasProperties.GetProperty<ClassProperty>("ClassInObject").MapPropertiesTo<EnumMapTo>();
// Assert
Assert.Equal(TestEnum.TestValue1, mappedProperty.EnumMapToEnum);
@ -196,7 +196,7 @@ public class HasPropertiesBaseTests
var hasProperties = new TestHasProperties(props);
// Act
var mappedProperty = hasProperties.MapClassPropertyTo<EnumWithFlagsMapTo>("ClassInObject");
var mappedProperty = hasProperties.GetProperty<ClassProperty>("ClassInObject").MapPropertiesTo<EnumWithFlagsMapTo>();
// Assert
Assert.Equal(TestEnumWithFlags.TestValue1 | TestEnumWithFlags.TestValue2, mappedProperty.EnumWithFlagsMapToEnum);

View file

@ -32,14 +32,6 @@ public interface IHasProperties
/// <returns>The property with the specified name.</returns>
T GetProperty<T>(string name) where T : IProperty;
/// <summary>
/// Maps a class property to a new instance of the specified type using reflection.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="name">The property which you want to map to a class</param>
/// <returns></returns>
T MapClassPropertyTo<T>(string name) where T : new();
/// <summary>
/// Maps all properties in this object to a new instance of the specified type using reflection.
/// </summary>
@ -85,13 +77,6 @@ public abstract class HasPropertiesBase : IHasProperties
return false;
}
/// <inheritdoc/>
public T MapClassPropertyTo<T>(string name) where T : new()
{
var classProperty = GetProperty<ClassProperty>(name);
return CreateMappedInstance<T>(classProperty.GetProperties());
}
/// <inheritdoc/>
public T MapPropertiesTo<T>() where T : new()
{