예제 #1
0
 public HomeController(ILocalizationService localizationService, IWebSettingsService webSettingsService, ICountryService countryService, ILogger <HomeController> logger)
 {
     _localizationService = localizationService;
     _webSettingsService  = webSettingsService;
     _countryService      = countryService;
     _logger = logger;
 }
        public void Init()
        {
            var services = new ServiceCollection();

            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "test_db")
                          .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking)
                          .Options;

            _memoryDbContext = new ApplicationDbContext(options);

            //Arrange
            var _localizationRepo = Substitute.For <ILocalizationRepository>();
            var _loggerRepo       = Substitute.For <ILogger <WebSettingsService> >();
            var _userStore        = Substitute.For <IUserStore <ApplicationUser> >();
            var _userManager      = Substitute.For <UserManager <ApplicationUser> >(_userStore, null, null, null, null, null, null, null, null);

            services.AddTransient <IWebSettingsRepository, WebSettingsRepository>();
            var serviceProvider = services.BuildServiceProvider();

            _webSettingsRepository = new WebSettingsRepository(_memoryDbContext);
            _webSettingsService    = Substitute.For <WebSettingsService>(_webSettingsRepository, _localizationRepo,
                                                                         _loggerRepo, _userManager);

            _webSettings = new FakeDbSet <WebSettings>(
                Builder <WebSettings> .CreateListOfSize(10)
                .All()
                .With(c => c.ID            = Guid.NewGuid())
                .With(cid => cid.CountryId = CountryId).Build());

            if (_memoryDbContext.WebSettings.Count() == 0)
            {
                _memoryDbContext.WebSettings.AddRange(_webSettings);
                _memoryDbContext.SaveChanges();
            }
        }
 public WebSettingsApiController(IWebSettingsService webSettingsService)
 {
     _webSettingsService = webSettingsService;
 }
예제 #4
0
 public MailSender(IWebSettingsService webSettingsService)
 {
     _webSettingsService = webSettingsService;
 }