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); }
public ThemeService( IUnitOfWorkFactory unitOfWorkFactory, DefaultThemeConfiguration defaultThemeConfiguration) { _unitOfWorkFactory = unitOfWorkFactory; _defaultThemeConfiguration = defaultThemeConfiguration; }
private static void RegisterDefaultThemeConfiguration(IMutableDependencyResolver services, IConfiguration configuration) { var config = new DefaultThemeConfiguration(); configuration.GetSection("Themes").Bind(config); services.RegisterConstant(config); }