Added web module tests
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Tests.Core.Models;
|
||||
using Moq;
|
||||
|
||||
namespace HopFrame.Tests.Core.Config;
|
||||
|
||||
public class DbContextConfiguratorTests {
|
||||
[Fact]
|
||||
public void Table_WithConfigurator_InvokesConfigurator() {
|
||||
// Arrange
|
||||
var dbContextConfig = new DbContextConfig(typeof(MockDbContext));
|
||||
var configurator = new DbContextConfigurator<MockDbContext>(dbContextConfig);
|
||||
var mockConfigurator = new Mock<Action<TableConfigurator<MockModel>>>();
|
||||
|
||||
// Act
|
||||
configurator.Table<MockModel>(mockConfigurator.Object);
|
||||
|
||||
// Assert
|
||||
mockConfigurator.Verify(c => c.Invoke(It.IsAny<TableConfigurator<MockModel>>()), Times.Once);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Table_ReturnsCorrectTableConfigurator() {
|
||||
// Arrange
|
||||
var dbContextConfig = new DbContextConfig(typeof(MockDbContext));
|
||||
var configurator = new DbContextConfigurator<MockDbContext>(dbContextConfig);
|
||||
|
||||
// Act
|
||||
var tableConfigurator = configurator.Table<MockModel>();
|
||||
|
||||
// Assert
|
||||
Assert.IsType<TableConfigurator<MockModel>>(tableConfigurator);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Tests.Core.Models;
|
||||
|
||||
namespace HopFrame.Tests.Core.Config;
|
||||
|
||||
public class HopFrameConfiguratorTests {
|
||||
[Fact]
|
||||
public void AddDbContext_AddsDbContextToInnerConfig() {
|
||||
// Arrange
|
||||
var config = new HopFrameConfig();
|
||||
var configurator = new HopFrameConfigurator(config);
|
||||
|
||||
// Act
|
||||
var dbContextConfigurator = configurator.AddDbContext<MockDbContext>();
|
||||
|
||||
// Assert
|
||||
Assert.Single(config.Contexts);
|
||||
Assert.IsType<DbContextConfig>(config.Contexts[0]);
|
||||
Assert.IsType<DbContextConfigurator<MockDbContext>>(dbContextConfigurator);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddDbContext_WithConfigurator_AddsDbContextToInnerConfig() {
|
||||
// Arrange
|
||||
var config = new HopFrameConfig();
|
||||
var configurator = new HopFrameConfigurator(config);
|
||||
|
||||
// Act
|
||||
object dbContextConfigurator = null!;
|
||||
configurator.AddDbContext<MockDbContext>(context => {
|
||||
dbContextConfigurator = context;
|
||||
});
|
||||
|
||||
// Assert
|
||||
Assert.Single(config.Contexts);
|
||||
Assert.IsType<DbContextConfig>(config.Contexts[0]);
|
||||
Assert.IsType<DbContextConfigurator<MockDbContext>>(dbContextConfigurator);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DisplayUserInfo_SetsDisplayUserInfoProperty() {
|
||||
// Arrange
|
||||
var config = new HopFrameConfig();
|
||||
var configurator = new HopFrameConfigurator(config);
|
||||
|
||||
// Act
|
||||
configurator.DisplayUserInfo(false);
|
||||
|
||||
// Assert
|
||||
Assert.False(config.DisplayUserInfo);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetBasePolicy_SetsBasePolicyProperty() {
|
||||
// Arrange
|
||||
var config = new HopFrameConfig();
|
||||
var configurator = new HopFrameConfigurator(config);
|
||||
var basePolicy = "Admin";
|
||||
|
||||
// Act
|
||||
configurator.SetBasePolicy(basePolicy);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(basePolicy, config.BasePolicy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetLoginPage_SetsLoginPageRewriteProperty() {
|
||||
// Arrange
|
||||
var config = new HopFrameConfig();
|
||||
var configurator = new HopFrameConfigurator(config);
|
||||
var loginPageUrl = "/login";
|
||||
|
||||
// Act
|
||||
configurator.SetLoginPage(loginPageUrl);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(loginPageUrl, config.LoginPageRewrite);
|
||||
}
|
||||
}
|
||||
225
tests/HopFrame.Tests.Core/Config/PropertyConfiguratorTests.cs
Normal file
225
tests/HopFrame.Tests.Core/Config/PropertyConfiguratorTests.cs
Normal file
@@ -0,0 +1,225 @@
|
||||
using System.Linq.Expressions;
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Tests.Core.Models;
|
||||
|
||||
namespace HopFrame.Tests.Core.Config;
|
||||
|
||||
public class PropertyConfiguratorTests {
|
||||
[Fact]
|
||||
public void SetDisplayName_SetsNameProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
var displayName = "ID";
|
||||
|
||||
// Act
|
||||
configurator.SetDisplayName(displayName);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(displayName, propertyConfig.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void List_SetsListAndSearchableProperties() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.List(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.List);
|
||||
Assert.False(propertyConfig.Searchable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsSortable_SetsSortableProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.IsSortable(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.Sortable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsSearchable_SetsSearchableProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.IsSearchable(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.Searchable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetDisplayedProperty_SetsDisplayedProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<MockModel>(propertyConfig);
|
||||
Expression<Func<MockModel, int>> propertyExpression = model => model.Id;
|
||||
|
||||
// Act
|
||||
configurator.SetDisplayedProperty(propertyExpression);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(propertyConfig.DisplayedProperty);
|
||||
Assert.Equal("Id", propertyConfig.DisplayedProperty?.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Format_SetsFormatter() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
Func<int, IServiceProvider, string> formatter = (val, _) => val.ToString();
|
||||
|
||||
// Act
|
||||
configurator.Format(formatter);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(propertyConfig.Formatter);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetParser_SetsParser() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
Func<string, IServiceProvider, int> parser = (str, _) => int.Parse(str);
|
||||
|
||||
// Act
|
||||
configurator.SetParser(parser);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(propertyConfig.Parser);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetEditable_SetsEditableProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.SetEditable(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.Editable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetCreatable_SetsCreatableProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.SetCreatable(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.Creatable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DisplayValue_SetsDisplayValueProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.DisplayValue(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.DisplayValue);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsTextArea_SetsTextAreaProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
|
||||
// Act
|
||||
configurator.IsTextArea(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(propertyConfig.TextArea);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetTextAreaRows_SetsTextAreaRowsProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
var rows = 10;
|
||||
|
||||
// Act
|
||||
configurator.SetTextAreaRows(rows);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(rows, propertyConfig.TextAreaRows);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetValidator_SetsValidator() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
Func<int, IServiceProvider, IEnumerable<string>> validator = (_, _) => new List<string>();
|
||||
|
||||
// Act
|
||||
configurator.SetValidator(validator);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(propertyConfig.Validator);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetOrderIndex_SetsOrderProperty() {
|
||||
// Arrange
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!,
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0), 0);
|
||||
var configurator = new PropertyConfigurator<int>(propertyConfig);
|
||||
var orderIndex = 1;
|
||||
|
||||
// Act
|
||||
configurator.SetOrderIndex(orderIndex);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(orderIndex, propertyConfig.Order);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_SetsTableProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
|
||||
// Act
|
||||
var propertyConfig = new PropertyConfig(typeof(MockModel).GetProperty("Id")!, tableConfig, 0);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(propertyConfig.Table);
|
||||
Assert.Equal(tableConfig, propertyConfig.Table);
|
||||
}
|
||||
}
|
||||
211
tests/HopFrame.Tests.Core/Config/TableConfiguratorTests.cs
Normal file
211
tests/HopFrame.Tests.Core/Config/TableConfiguratorTests.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
using System.Linq.Expressions;
|
||||
using HopFrame.Core.Config;
|
||||
using HopFrame.Tests.Core.Models;
|
||||
|
||||
namespace HopFrame.Tests.Core.Config;
|
||||
|
||||
public class TableConfiguratorTests {
|
||||
[Fact]
|
||||
public void Ignore_SetsIgnoredProperty() {
|
||||
// Arrange
|
||||
var tableConfig =
|
||||
new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
|
||||
// Act
|
||||
configurator.Ignore(true);
|
||||
|
||||
// Assert
|
||||
Assert.True(tableConfig.Ignored);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Property_ReturnsCorrectPropertyConfigurator() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
Expression<Func<MockModel, int>> propertyExpression = model => model.Id;
|
||||
|
||||
// Act
|
||||
var propertyConfigurator = configurator.Property(propertyExpression);
|
||||
|
||||
// Assert
|
||||
Assert.IsType<PropertyConfigurator<int>>(propertyConfigurator);
|
||||
}
|
||||
|
||||
public void Property_WithConfigurator_ReturnsCorrectPropertyConfigurator() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
Expression<Func<MockModel, int>> propertyExpression = model => model.Id;
|
||||
|
||||
// Act
|
||||
object propertyConfigurator = null!;
|
||||
configurator.Property(propertyExpression, c => {
|
||||
propertyConfigurator = c;
|
||||
});
|
||||
|
||||
// Assert
|
||||
Assert.IsType<PropertyConfigurator<int>>(propertyConfigurator);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddVirtualProperty_AddsVirtualPropertyToConfig() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
Func<MockModel, IServiceProvider, string> template = (model, _) => model.Name!;
|
||||
|
||||
// Act
|
||||
var propertyConfigurator = configurator.AddVirtualProperty("VirtualName", template);
|
||||
|
||||
// Assert
|
||||
var virtualProperty = tableConfig.Properties.SingleOrDefault(p => p.Name == "VirtualName");
|
||||
Assert.NotNull(virtualProperty);
|
||||
Assert.NotNull(propertyConfigurator);
|
||||
Assert.True(virtualProperty.IsListingProperty);
|
||||
Assert.Equal("VirtualName", virtualProperty.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AddVirtualProperty_WithConfigurator_AddsVirtualPropertyToConfig() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
Func<MockModel, IServiceProvider, string> template = (model, _) => model.Name!;
|
||||
|
||||
// Act
|
||||
object propertyConfigurator = null!;
|
||||
configurator.AddVirtualProperty("VirtualName", template, c => {
|
||||
propertyConfigurator = c;
|
||||
});
|
||||
|
||||
// Assert
|
||||
var virtualProperty = tableConfig.Properties.SingleOrDefault(p => p.Name == "VirtualName");
|
||||
Assert.NotNull(virtualProperty);
|
||||
Assert.NotNull(propertyConfigurator);
|
||||
Assert.True(virtualProperty.IsListingProperty);
|
||||
Assert.Equal("VirtualName", virtualProperty.Name);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetDisplayName_SetsDisplayNameProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var displayName = "Mock Model Display Name";
|
||||
|
||||
// Act
|
||||
configurator.SetDisplayName(displayName);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(displayName, tableConfig.DisplayName);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetDescription_SetsDescriptionProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var description = "Mock Model Description";
|
||||
|
||||
// Act
|
||||
configurator.SetDescription(description);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(description, tableConfig.Description);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetOrderIndex_SetsOrderIndexProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var orderIndex = 1;
|
||||
|
||||
// Act
|
||||
configurator.SetOrderIndex(orderIndex);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(orderIndex, tableConfig.Order);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetViewPolicy_SetsViewPolicyProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var policy = "ViewPolicy";
|
||||
|
||||
// Act
|
||||
configurator.SetViewPolicy(policy);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(policy, tableConfig.ViewPolicy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetUpdatePolicy_SetsUpdatePolicyProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var policy = "UpdatePolicy";
|
||||
|
||||
// Act
|
||||
configurator.SetUpdatePolicy(policy);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(policy, tableConfig.UpdatePolicy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetCreatePolicy_SetsCreatePolicyProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var policy = "CreatePolicy";
|
||||
|
||||
// Act
|
||||
configurator.SetCreatePolicy(policy);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(policy, tableConfig.CreatePolicy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SetDeletePolicy_SetsDeletePolicyProperty() {
|
||||
// Arrange
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel), "MockModels", 0);
|
||||
var configurator = new TableConfigurator<MockModel>(tableConfig);
|
||||
var policy = "DeletePolicy";
|
||||
|
||||
// Act
|
||||
configurator.SetDeletePolicy(policy);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(policy, tableConfig.DeletePolicy);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithKeyProperty_DisablesEdit() {
|
||||
// Act
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel2), "Models2", 0);
|
||||
var prop = tableConfig.Properties.SingleOrDefault(prop => prop.Info.Name == nameof(MockModel2.Id));
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(prop);
|
||||
Assert.False(prop.Editable);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_WithGeneratedProperty_DisablesEditAndCreate() {
|
||||
// Act
|
||||
var tableConfig = new TableConfig(new DbContextConfig(typeof(MockDbContext)), typeof(MockModel2), "Models2", 0);
|
||||
var prop = tableConfig.Properties.SingleOrDefault(prop => prop.Info.Name == nameof(MockModel2.Number));
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(prop);
|
||||
Assert.False(prop.Editable);
|
||||
Assert.False(prop.Creatable);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user