/// <summary> /// Create <see cref="HomeControllerTests"/>. /// </summary> public HomeControllerTests() { // Database setup var services = new ServiceCollection(); services.AddEntityFrameworkInMemoryDatabase() .AddDbContext <DataDbContext>(options => options.UseInMemoryDatabase() ); // Dependencies initializations _pageConfiguration = new FakePageConfiguration(); var optionsBuilder = new DbContextOptionsBuilder <DataDbContext>(); optionsBuilder.UseInMemoryDatabase(); _dataDbContext = new DataDbContext(optionsBuilder.Options); _contentRepository = new ContentRepository(_dataDbContext); _humanReadableContentService = new HumanReadableContentRetrievalService(_pageConfiguration, _contentRepository); _languageManipulationService = new LanguageManipulationService(); // Controller initialization _homeController = new HomeController( _pageConfiguration, _humanReadableContentService, _languageManipulationService ); }
/// <summary> /// Create <see cref="HomeController"/>. /// </summary> /// <param name="pageConfiguration">Page configuration.</param> /// <param name="humanReadableContentService">Human-readable content retrieval service.</param> /// <param name="languageManipulationService">Language manipulation service.</param> public HomeController( IPageConfiguration pageConfiguration, IHumanReadableContentRetrievalService humanReadableContentService, ILanguageManipulationService languageManipulationService) { _pageConfiguration = pageConfiguration ?? throw new ArgumentNullException(nameof(pageConfiguration)); _humanReadableContentService = humanReadableContentService ?? throw new ArgumentNullException(nameof(humanReadableContentService)); _languageManipulationService = languageManipulationService ?? throw new ArgumentNullException(nameof(languageManipulationService)); }
/// <summary> /// Create <see cref="ContentsController"/>. /// </summary> /// <param name="pageConfiguration">Page configuration.</param> /// <param name="humanReadableContentService">Human-readable content retrieval service.</param> /// <param name="languageManipulationService">Language manipulation service.</param> public ContentsController( IPageConfiguration pageConfiguration, IHumanReadableContentRetrievalService humanReadableContentService, ILanguageManipulationService languageManipulationService) { if (pageConfiguration == null) { throw new ArgumentNullException(nameof(pageConfiguration)); } if (humanReadableContentService == null) { throw new ArgumentNullException(nameof(humanReadableContentService)); } if (languageManipulationService == null) { throw new ArgumentNullException(nameof(languageManipulationService)); } _humanReadableContentService = humanReadableContentService; _languageManipulationService = languageManipulationService; _pageConfiguration = pageConfiguration; }