コード例 #1
0
ファイル: NonApiMiddlewareTests.cs プロジェクト: HarelM/Site
        public void TestInitialize()
        {
            _hostingEnvironment       = Substitute.For <IWebHostEnvironment>();
            _serviceProvider          = Substitute.For <IServiceProvider>();
            _repository               = Substitute.For <IRepository>();
            _pointsOfInterestProvider = Substitute.For <IPointsOfInterestProvider>();
            var config  = new ConfigurationData();
            var options = Substitute.For <IOptions <ConfigurationData> >();

            options.Value.Returns(config);
            _middleware = new NonApiMiddleware(null, _hostingEnvironment, _repository, _pointsOfInterestProvider, options);
        }
コード例 #2
0
        public async Task <IActionResult> GetHtml(string id)
        {
            _logger.LogDebug("Received a call to get html for: " + id);
            var url = await _repository.GetUrlById(id);

            var title         = string.IsNullOrWhiteSpace(url.Title) ? "Israel Hiking Map Route Share" : url.Title;
            var contentResult = new ContentResult
            {
                Content     = NonApiMiddleware.GetPage(title, Url.Content("~/api/images/" + url.Id), url.Description),
                ContentType = "text/html"
            };

            return(contentResult);
        }
コード例 #3
0
        public void TestInitialize()
        {
            _hostingEnvironment = Substitute.For <IHostingEnvironment>();
            _serviceProvider    = Substitute.For <IServiceProvider>();
            var browserResolver = Substitute.For <IBrowserResolver>();
            var browser         = Substitute.For <IBrowser>();

            browser.Type.Returns(BrowserType.Generic);
            browserResolver.Browser.Returns(browser);
            var userAgentService = Substitute.For <IUserAgentService>();
            var userAgent        = Substitute.For <IUserAgent>();

            userAgent.ToString().Returns("WhatsApp1.2.3");
            userAgentService.UserAgent.Returns(userAgent);
            _serviceProvider.GetService(typeof(IBrowserResolver)).Returns(browserResolver);
            _serviceProvider.GetService(typeof(IUserAgentService)).Returns(userAgentService);
            _repository = Substitute.For <IRepository>();
            _pointsOfInterestAggregatorService = Substitute.For <IPointsOfInterestAggregatorService>();
            var config  = new ConfigurationData();
            var options = Substitute.For <IOptions <ConfigurationData> >();

            options.Value.Returns(config);
            _middleware = new NonApiMiddleware(null, _hostingEnvironment, _serviceProvider, _repository, _pointsOfInterestAggregatorService, options);
        }