public async Task <AssetAttributeIdentityDTO> CreateTestAssetAttribute() { AssetAttributesEntity testAssetAttr = EnumerableUtils.PickRandom(AllAssetAttributesFromDB); string url = ApiPaths.ASSET_ATTRIBUTES_PATH + "/" + testAssetAttr.AssetId; string newKey = testAssetAttr.Key + Helpers.Random.Next(1000, 9999).ToString() + GlobalConstants.AutoTest; string newValue = Helpers.Random.Next(1000, 9999).ToString() + "_autotest"; AssetAttributeDTO createParameter = new AssetAttributeDTO() { Key = newKey, Value = newValue }; var response = await Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(createParameter), Method.POST); if (response.Status != HttpStatusCode.Created) { return(null); } AssetAttributeIdentityDTO returnModel = new AssetAttributeIdentityDTO() { AssetId = testAssetAttr.AssetId, Key = newKey, Value = newValue }; AddOneTimeCleanupAction(async() => await DeleteTestAssetAttribute(returnModel.AssetId, returnModel.Key)); return(returnModel); }
public async Task GetSingleAssetAttribute() { string url = ApiPaths.ASSET_ATTRIBUTES_PATH + "/" + this.TestAssetAttribute.AssetId + "/" + this.TestAssetAttribute.Key; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, null, Method.GET); Assert.True(response.Status == HttpStatusCode.OK); Assert.NotNull(response.ResponseJson); AssetAttributeDTO parsedResponse = JsonUtils.DeserializeJson <AssetAttributeDTO>(response.ResponseJson); Assert.True(this.TestAssetAttribute.Value == parsedResponse.Value); }