Пример #1
0
        public void RenderAccess_With_Cache_ViewPort_then_Conversion()
        {
            var rc       = new GameRenderingConfig(RenderType.Grid);
            var renderer = new RendererSubstitute <RenderedTile, RenderedContext>();
            var conv     = new ConverterProxy();
            var matcher  = new DummyTileMatcher <MatchedTile, MatchedContext>();

            var sourceFactory = PlotOperations.FromContext(rc).Create(matcher);
            var cachedFactory = sourceFactory.WithCache();
            var vpFactory     = cachedFactory.ForViewport();
            var convRend      = vpFactory.WithConversion(conv).Build();

            var sourcePo = sourceFactory.BuildUnsafe();
            var cached   = cachedFactory.BuildUnsafe();
            var vp       = vpFactory.Build();

            sourcePo.Renderer.Should().Be(cached.ActiveRenderer);
            sourcePo.ActiveRenderer.Should().Be(cached.ActiveRenderer);

            convRend.Renderer = renderer;

            Assert.AreEqual(vp.ActiveRenderer, cached.Renderer);
            Assert.AreEqual(vp.Renderer, conv);

            sourcePo.Renderer.Should().Be(cached.ActiveRenderer);
            sourcePo.ActiveRenderer.Should().Be(cached.ActiveRenderer);

            vp.ActiveRenderer.Should().BeAssignableTo <ViewportRenderer <MatchedTile, MatchedContext> >();
        }
Пример #2
0
        private async static Task SwaggerBasedClient(HttpClient httpClient)
        {
            ConverterProxy converter = new ConverterProxy(httpClient);

            foreach (string symbol in new[] { "USD", "XXX" })
            {
                try
                {
                    SwaggerResponse <ProxyDomain.CurrencyData> data = await converter.GetBySymbolAsync(symbol);

                    Console.WriteLine($"{data.Result.Symbol}");
                } catch (SwaggerException se)
                {
                    Console.WriteLine($"SwaggerException: StatusCode={se.StatusCode}, Message={se.Message.FirstLine()}");
                }
            }
        }
Пример #3
0
        public void RenderAccess_With_Cache_ViewPort()
        {
            var rc       = new GameRenderingConfig(RenderType.Grid);
            var renderer = new RendererSubstitute <RenderedTile, RenderedContext>();
            var conv     = new ConverterProxy();
            var matcher  = new DummyTileMatcher <RenderedTile, RenderedContext>();

            var cache =
                PlotOperations.FromContext(rc)
                .Create(matcher)
                .WithCache()
                .ForViewport()
                .WithRenderer(renderer)
                .Build();

            var s = cache.ActiveRenderer.Should().BeAssignableTo <ViewportRenderer <RenderedTile, RenderedContext> >().Subject;
            //s.RenderTarget.Should().BeAssignableTo<ViewportRenderer<RenderedTile, RenderedContext>>();
        }
        private static async Task TestSwaggerClientAsync()
        {
            var client         = new HttpClient();
            var converterProxy = new ConverterProxy(client);

            foreach (var symbol in new[] { "USD", "test" })
            {
                try
                {
                    SwaggerResponse <Proxy.CurrencyData> data =
                        await converterProxy.GetBySymbolAsync(symbol);

                    Console.WriteLine($"{data.Result.Name} ({data.Result.Symbol}, {data.Result.Country}, {data.Result.EuroRate})");
                }
                catch (SwaggerException se)
                {
                    Console.WriteLine($"{se.StatusCode}: {se.Message}");
                }
            }
        }
Пример #5
0
        public void RenderAccess_With_Conversion()
        {
            var rc       = new GameRenderingConfig(RenderType.Grid);
            var renderer = new RendererSubstitute <RenderedTile, RenderedContext>();
            var conv     = new ConverterProxy();
            var matcher  = new DummyTileMatcher <MatchedTile, MatchedContext>();

            var sourceFactory = PlotOperations.FromContext(rc).Create(matcher);
            var plot          = sourceFactory.WithConversion(conv).BuildUnsafe();

            var sourcePo = sourceFactory.BuildUnsafe();

            sourcePo.Renderer.Should().Be(conv);
            sourcePo.ActiveRenderer.Should().Be(conv);
            plot.ActiveRenderer.Should().BeNull();

            plot.Renderer = renderer;
            Assert.AreEqual(plot.Renderer, renderer);
            Assert.AreEqual(plot.ActiveRenderer, renderer);
            sourcePo.Renderer.Should().Be(conv);
            sourcePo.ActiveRenderer.Should().Be(conv);
        }