Added web module tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user