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 CreateAssetAttribute() { AssetAttributeIdentityDTO newAssetAttr = await this.CreateTestAssetAttribute(); Assert.NotNull(newAssetAttr); var checkDb = await this.AssetAttributesRepository.TryGetAsync(newAssetAttr.AssetId, newAssetAttr.Key); Assert.True(checkDb.Value == newAssetAttr.Value); }
public async Task DeleteAssetAttribute() { AssetAttributeIdentityDTO TestAssetAttributeDelete = await CreateTestAssetAttribute(); string deleteUrl = ApiPaths.ASSET_ATTRIBUTES_PATH + "/" + TestAssetAttributeDelete.AssetId + "/" + TestAssetAttributeDelete.Key; var deleteResponse = await this.Consumer.ExecuteRequest(deleteUrl, Helpers.EmptyDictionary, null, Method.DELETE); Assert.True(deleteResponse.Status == HttpStatusCode.NoContent); var checkDbDeleted = await this.AssetAttributesRepository.TryGetAsync(TestAssetAttributeDelete.AssetId, TestAssetAttributeDelete.Key); Assert.Null(checkDbDeleted); }
public async Task UpdateAssetAttribute() { AssetAttributeIdentityDTO TestAssetAttributeUpdate = await CreateTestAssetAttribute(); string url = ApiPaths.ASSET_ATTRIBUTES_PATH + "/" + TestAssetAttributeUpdate.AssetId; string updateValue = TestAssetAttributeUpdate.Value + "_AutoTestEdit"; string updateParameter = JsonUtils.SerializeObject( new AssetAttributeDTO() { Key = TestAssetAttributeUpdate.Key, Value = updateValue }); var updateResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, updateParameter, Method.PUT); Assert.True(updateResponse.Status == HttpStatusCode.NoContent); var checkDbUpdated = await this.AssetAttributesRepository.TryGetAsync(TestAssetAttributeUpdate.AssetId, TestAssetAttributeUpdate.Key); Assert.True(checkDbUpdated.Value == updateValue); }