示例#1
0
        public async Task UpdateAssetPair()
        {
            string url = ApiPaths.ASSET_PAIRS_PATH;

            AssetPairDTO TestAssetPairUpdate = await CreateTestAssetPair();

            AssetPairDTO updateAssetPair = new AssetPairDTO()
            {
                Accuracy         = Helpers.Random.Next(2, 8),
                BaseAssetId      = TestAssetPairUpdate.BaseAssetId,
                Id               = TestAssetPairUpdate.Id,
                InvertedAccuracy = TestAssetPairUpdate.InvertedAccuracy,
                IsDisabled       = TestAssetPairUpdate.IsDisabled,
                Name             = TestAssetPairUpdate.Name + Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest,
                QuotingAssetId   = TestAssetPairUpdate.QuotingAssetId,
                Source           = TestAssetPairUpdate.Source,
                Source2          = TestAssetPairUpdate.Source2
            };
            string updateParam = JsonUtils.SerializeObject(updateAssetPair);

            var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, updateParam, Method.PUT);

            Assert.NotNull(response);
            Assert.True(response.Status == HttpStatusCode.NoContent);

            AssetPairEntity entity = await this.AssetPairManager.TryGetAsync(updateAssetPair.Id) as AssetPairEntity;

            entity.ShouldBeEquivalentTo(updateAssetPair, o => o
                                        .ExcludingMissingMembers());
        }
示例#2
0
        public async Task CreateAssetPair()
        {
            AssetPairDTO newAssetPair = await this.CreateTestAssetPair();

            Assert.NotNull(newAssetPair);

            AssetPairEntity entity = await this.AssetPairManager.TryGetAsync(newAssetPair.Id) as AssetPairEntity;

            entity.ShouldBeEquivalentTo(newAssetPair, o => o
                                        .ExcludingMissingMembers());
        }
示例#3
0
        public async Task GetSingleAssetPair()
        {
            string url      = ApiPaths.ASSET_PAIRS_PATH + "/" + this.TestAssetPair.Id;
            var    response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.GET);

            Assert.NotNull(response);
            Assert.True(response.Status == HttpStatusCode.OK);

            AssetPairDTO parsedResponse = JsonUtils.DeserializeJson <AssetPairDTO>(response.ResponseJson);

            this.TestAssetPair.ShouldBeEquivalentTo(parsedResponse, o => o
                                                    .ExcludingMissingMembers());
        }
示例#4
0
        public async Task DeleteAssetPair()
        {
            AssetPairDTO TestAssetPairDelete = await CreateTestAssetPair();

            string url    = ApiPaths.ASSET_PAIRS_PATH + "/" + TestAssetPairDelete.Id;
            var    result = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.DELETE);

            Assert.NotNull(result);
            Assert.True(result.Status == HttpStatusCode.NoContent);

            AssetPairEntity entity = await this.AssetPairManager.TryGetAsync(TestAssetPairDelete.Id) as AssetPairEntity;

            Assert.Null(entity);
        }
示例#5
0
        public async Task <AssetPairDTO> CreateTestAssetPair()
        {
            string          url            = ApiPaths.ASSET_PAIRS_PATH;
            AssetPairEntity templateEntity = EnumerableUtils.PickRandom(AllAssetPairsFromDB);
            AssetPairDTO    createDTO      = this.mapper.Map <AssetPairDTO>(templateEntity);

            createDTO.Id       = templateEntity.Id + Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest;
            createDTO.Name    += Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest;
            createDTO.Accuracy = Helpers.Random.Next(2, 8);
            string createParam = JsonUtils.SerializeObject(createDTO);

            var response = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, createParam, Method.POST);

            if (response.Status != HttpStatusCode.Created)
            {
                return(null);
            }

            AddOneTimeCleanupAction(async() => await DeleteTestAssetPair(createDTO.Id));

            return(createDTO);
        }