Ejemplo n.º 1
0
        public SearchSuggestionsServiceTest()
        {
            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();

            _memoryCache = provider.GetService <IMemoryCache>();

            var builder = new DbContextOptionsBuilder <ApplicationDbContext>();

            builder.UseInMemoryDatabase("searchSuggestionService");
            var options = builder.Options;

            _dbContext = new ApplicationDbContext(options);
            _suggest   = new SearchSuggestionsService(_dbContext, _memoryCache, new FakeIWebLogger(), new AppSettings());
            _query     = new Query(_dbContext, new AppSettings(), null, new FakeIWebLogger(), _memoryCache);
        }
Ejemplo n.º 2
0
        public async Task SearchSuggestionsService_MySqlError()
        {
            var provider = new ServiceCollection()
                           .AddMemoryCache()
                           .BuildServiceProvider();

            var builder = new DbContextOptionsBuilder <ApplicationDbContext>();

            builder.UseMySql("Server=test;database=test;uid=test;pwd=test;", new MariaDbServerVersion("10.2"));
            var options    = builder.Options;
            var dbContext  = new ApplicationDbContext(options);
            var fakeLogger = new FakeIWebLogger();
            var suggest    = new SearchSuggestionsService(dbContext, _memoryCache, fakeLogger, new AppSettings());

            await suggest.Inflate();

            Assert.AreEqual("mysql search suggest exception catch-ed", fakeLogger.TrackedExceptions.LastOrDefault().Item2);
        }
 public ProductsController(IUnitOfWork unitOfWork, SearchSuggestionsService searchSuggestionsService, IPageService pageService)
 {
     this.unitOfWork = unitOfWork;
     this.searchSuggestionsService = searchSuggestionsService;
     this.pageService = pageService;
 }