コード例 #1
0
ファイル: ThemeServiceTests.cs プロジェクト: tzinmein/Camelot
    public void TestGetCurrentTheme(int?themeId, Theme configTheme, Theme theme)
    {
        var repositoryMock = new Mock <IRepository <ThemeSettings> >();

        repositoryMock
        .Setup(m => m.GetById(ThemeSettingsId))
        .Returns(themeId.HasValue ? new ThemeSettings {
            SelectedTheme = themeId.Value
        } : null);

        var unitOfWorkMock = new Mock <IUnitOfWork>();

        unitOfWorkMock
        .Setup(m => m.GetRepository <ThemeSettings>())
        .Returns(repositoryMock.Object);

        _autoMocker
        .Setup <IUnitOfWorkFactory, IUnitOfWork>(m => m.Create())
        .Returns(unitOfWorkMock.Object);
        var defaultConfig = new DefaultThemeConfiguration
        {
            DefaultTheme = configTheme
        };

        _autoMocker.Use(defaultConfig);

        var themeService = _autoMocker.CreateInstance <ThemeService>();
        var currentTheme = themeService.GetCurrentTheme();

        Assert.Equal(theme, currentTheme);
    }
コード例 #2
0
ファイル: ThemeService.cs プロジェクト: omerfarukz/Camelot
 public ThemeService(
     IUnitOfWorkFactory unitOfWorkFactory,
     DefaultThemeConfiguration defaultThemeConfiguration)
 {
     _unitOfWorkFactory         = unitOfWorkFactory;
     _defaultThemeConfiguration = defaultThemeConfiguration;
 }
コード例 #3
0
    private static void RegisterDefaultThemeConfiguration(IMutableDependencyResolver services,
                                                          IConfiguration configuration)
    {
        var config = new DefaultThemeConfiguration();

        configuration.GetSection("Themes").Bind(config);
        services.RegisterConstant(config);
    }