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()); }
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()); }
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()); }
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); }
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); }