コード例 #1
0
        public HttpClientStreamStoreFixture()
        {
            _inMemoryStreamStore = new InMemoryStreamStore(() => GetUtcNow());

            var random = new Random();

            var segments = Enumerable.Range(0, random.Next(1, 3)).Select(_ => Guid.NewGuid()).ToArray();
            var basePath = $"/{string.Join("/", segments)}";

            var webHostBuilder = new WebHostBuilder()
                                 .ConfigureServices(services => services.AddSqlStreamStoreHal())
                                 .Configure(builder => builder.Map(basePath, inner => inner.UseSqlStreamStoreHal(_inMemoryStreamStore)));

            _server = new TestServer(webHostBuilder);

            var handler = new RedirectingHandler
            {
                InnerHandler = _server.CreateHandler()
            };

            Store = new HttpClientSqlStreamStore(
                new HttpClientSqlStreamStoreSettings
            {
                GetUtcNow   = () => GetUtcNow(),
                BaseAddress = new UriBuilder
                {
                    Path = basePath.Length == 1 ? basePath : $"{basePath}/"
                }.Uri,
                CreateHttpClient = () => new HttpClient(handler, false)
            });
        }
コード例 #2
0
        public HttpClientStreamStoreFixture2()
        {
            _inMemoryStreamStore = new InMemoryStreamStore(() => GetUtcNow());

            var webHostBuilder = new WebHostBuilder()
                                 .Configure(builder => builder.UseSqlStreamStoreHal(_inMemoryStreamStore));

            _server = new TestServer(webHostBuilder);

            var handler = new RedirectingHandler
            {
                InnerHandler = _server.CreateHandler()
            };

            Store = new HttpClientSqlStreamStore(
                new HttpClientSqlStreamStoreSettings
            {
                GetUtcNow          = () => GetUtcNow(),
                HttpMessageHandler = handler,
                BaseAddress        = new UriBuilder().Uri
            });
        }