예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }