Added ef core integration
This commit is contained in:
@@ -8,18 +8,23 @@ namespace HopFrame.Tests.Core.Configurators;
|
||||
|
||||
public class HopFrameConfiguratorTests {
|
||||
private class TestRepository : IHopFrameRepository {
|
||||
public Task<IEnumerable> LoadPageGenericAsync(int page, int perPage, CancellationToken ct = default) {
|
||||
public Task<IEnumerable> LoadPageGenericAsync(int page, int perPage, CancellationToken ct) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<int> CountAsync(CancellationToken ct = default) {
|
||||
public Task<int> CountAsync(CancellationToken ct) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task<IEnumerable> SearchGenericAsync(string searchTerm, int page, int perPage, CancellationToken ct = default) {
|
||||
public Task<IEnumerable> SearchGenericAsync(string searchTerm, int page, int perPage, CancellationToken ct) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public Task CreateGenericAsync(object entry, CancellationToken ct) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task UpdateGenericAsync(object entry, CancellationToken ct) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task DeleteGenericAsync(object entry, CancellationToken ct) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
@@ -41,7 +46,8 @@ public class HopFrameConfiguratorTests {
|
||||
Identifier = "Id",
|
||||
DisplayName = "Id",
|
||||
Type = typeof(int),
|
||||
OrderIndex = 0
|
||||
OrderIndex = 0,
|
||||
PropertyType = PropertyType.Numeric
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
using HopFrame.Core.Configuration;
|
||||
using HopFrame.Core.Configurators;
|
||||
|
||||
namespace HopFrame.Tests.Core.Configurators;
|
||||
|
||||
public class PropertyConfiguratorTests {
|
||||
private PropertyConfig CreateConfig(PropertyType type)
|
||||
=> new PropertyConfig {
|
||||
Identifier = "Test",
|
||||
DisplayName = "Test",
|
||||
Type = typeof(string),
|
||||
OrderIndex = 0,
|
||||
PropertyType = type
|
||||
};
|
||||
|
||||
[Fact]
|
||||
public void SetType_ReplacesBaseType_AndPreservesModifiers() {
|
||||
// Arrange: Nullable + List + Numeric
|
||||
var original = PropertyType.Numeric | PropertyType.Nullable | PropertyType.List;
|
||||
var config = CreateConfig(original);
|
||||
|
||||
var configurator = new PropertyConfigurator(config);
|
||||
|
||||
// Act: change base type to Text
|
||||
configurator.SetType(PropertyType.Text);
|
||||
|
||||
// Assert: modifiers remain, base type replaced
|
||||
Assert.Equal(
|
||||
PropertyType.Text | PropertyType.Nullable | PropertyType.List,
|
||||
config.PropertyType
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetType_DoesNotAffectModifiers_WhenSettingSameBaseType() {
|
||||
var original = PropertyType.Boolean | PropertyType.Nullable;
|
||||
var config = CreateConfig(original);
|
||||
|
||||
var configurator = new PropertyConfigurator(config);
|
||||
|
||||
configurator.SetType(PropertyType.Boolean);
|
||||
|
||||
Assert.Equal(original, config.PropertyType);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetType_CanChangeEnumToNumeric_WhileKeepingModifiers() {
|
||||
var original = PropertyType.Enum | PropertyType.List;
|
||||
var config = CreateConfig(original);
|
||||
|
||||
var configurator = new PropertyConfigurator(config);
|
||||
|
||||
configurator.SetType(PropertyType.Numeric);
|
||||
|
||||
Assert.Equal(
|
||||
PropertyType.Numeric | PropertyType.List,
|
||||
config.PropertyType
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetType_CanChangeToEmail_AndPreserveNullable() {
|
||||
var original = PropertyType.Text | PropertyType.Nullable;
|
||||
var config = CreateConfig(original);
|
||||
|
||||
var configurator = new PropertyConfigurator(config);
|
||||
|
||||
configurator.SetType(PropertyType.Email);
|
||||
|
||||
Assert.Equal(
|
||||
PropertyType.Email | PropertyType.Nullable,
|
||||
config.PropertyType
|
||||
);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetType_ReturnsConfigurator_ForFluentApi() {
|
||||
var config = CreateConfig(PropertyType.Text);
|
||||
var configurator = new PropertyConfigurator(config);
|
||||
|
||||
var result = configurator.SetType(PropertyType.Numeric);
|
||||
|
||||
Assert.Same(configurator, result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user