public void PostMarketConverterTest()
            {
                Step("Make POST /api/market/converter with valid parameters and validate response", () =>
                {
                    var assetsFrom = new List <AssetWithAmount>
                    {
                        new AssetWithAmount {
                            Amount = 10, AssetId = "BTC"
                        },
                        new AssetWithAmount {
                            Amount = 10, AssetId = "LKK"
                        }
                    };

                    ConvertionRequest model = new ConvertionRequest
                    {
                        AssetsFrom  = assetsFrom,
                        BaseAssetId = "USD",
                        OrderAction = "Sell"
                    };

                    var response = apiV2.Market.PostMarketConvertor(model);
                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
                    Assert.That(response.GetResponseObject().Converted.Count, Is.EqualTo(assetsFrom.Count));
                });
            }
            public void PostMarketConverterEmptyConverterRequestTest()
            {
                Step("Make POST /api/market/converter with empty request body and validate response", () =>
                {
                    ConvertionRequest model = new ConvertionRequest();

                    var response = apiV2.Market.PostMarketConvertor(model);

                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
                });
            }
Пример #3
0
        public void Converter_CheckIsMethodRegistered_ShouldPass()
        {
            var request =
                new ConvertionRequest <ConverterTests>(
                    "repeat every 5 seconds where TestA(@current) and TestB(@current) start at '06.06.2016 14:00:00'",
                    TimeZoneInfo.Local, TimeZoneInfo.Local, false, null);

            var timeline = new RdlTimeline <ConverterTests>(false);

            var response = timeline.Convert(request);

            response.Output.NextFire();

            Assert.IsTrue(_testACalled);
            Assert.IsTrue(_testBCalled);
        }
        public async Task <IActionResult> Convert([FromBody] ConvertionRequest request)
        {
            var orderAction = BaseOrderExt.GetOrderAction(request.OrderAction);

            if (orderAction == null)
            {
                ModelState.AddModelError("OrderAction", request.OrderAction);
                return(BadRequest(ModelState));
            }

            var result = await _rateCalculator.GetMarketAmountInBaseAsync(request.AssetsFrom, request.BaseAssetId,
                                                                          orderAction.Value.ToRateCalculatorDomain());

            return(Ok(new ConvertionResponse {
                Converted = result.ToArray()
            }));
        }
Пример #5
0
        private void TestMethods <TMethods>(string query, string fireTime) where TMethods : new()
        {
            var request = new ConvertionRequest <TMethods>(query, TimeZoneInfo.Local, TimeZoneInfo.Local, false, new[]
            {
                "dd.M.yyyy",
                "dd.M.yyyy hh:mm:ss"
            });

            var timeline = new RdlTimeline <TMethods>(false);
            var response = timeline.Convert(request);

            Assert.IsNotNull(response.Output);

            var fireAt = response.Output.NextFire();

            Assert.AreEqual(DateTimeOffset.Parse(fireTime), fireAt.Value);
        }
Пример #6
0
        public static ConvertionResponse <IFireTimeEvaluator> Convert <TMethodsAggregator>(string query, TimeZoneInfo source, TimeZoneInfo destination, CancellationToken cancellationToken = default(CancellationToken))
            where TMethodsAggregator : new()
        {
            var request
                = new ConvertionRequest <TMethodsAggregator>(query, source, destination, false, new[]
            {
                "dd/M/yyyy H:m:s",
                "dd/M/yyyy h:m:s tt",
                "dd.M.yyyy H:m:s",
                "dd.M.yyyy h:m:s tt",
                "yyyy-mm.dd HH:mm:ss",
                "yyyy/mm/dd H:m:s",
                "dd.M.yyyy"
            }, cancellationToken);

            var timeline = new RdlTimeline <TMethodsAggregator>(false);

            var response = timeline.Convert(request);

            return(response);
        }
            public void PostMarketConverterNoBaseAssetTest()
            {
                Step("Make POST /api/market/converter without BaseAssetId and validate response", () =>
                {
                    var assetsFrom = new List <AssetWithAmount>
                    {
                        new AssetWithAmount {
                            Amount = 10, AssetId = "BTC"
                        },
                        new AssetWithAmount {
                            Amount = 10, AssetId = "LKK"
                        }
                    };

                    ConvertionRequest model = new ConvertionRequest
                    {
                        AssetsFrom  = assetsFrom,
                        OrderAction = "Sell"
                    };

                    var response = apiV2.Market.PostMarketConvertor(model);
                    Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
                });
            }
Пример #8
0
 public IResponse <ConvertionResponse> PostMarketConvertor(ConvertionRequest model)
 {
     return(Request.Post("/market/converter").AddJsonBody(model).Build().Execute <ConvertionResponse>());
 }