Exemple #1
0
        public async Task EditMetadataBadRequest(string badName)
        {
            string url = ApiPaths.ALGO_STORE_METADATA;

            MetaDataDTO metadata = new MetaDataDTO()
            {
                Name        = Helpers.RandomString(8),
                Description = Helpers.RandomString(8)
            };

            var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST);

            Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK));
            MetaDataResponseDTO responceMetaData = JsonUtils.DeserializeJson <MetaDataResponseDTO>(response.ResponseJson);

            url = ApiPaths.ALGO_STORE_METADATA;

            MetaDataEditDTO editMetaData = new MetaDataEditDTO()
            {
                Id          = responceMetaData.Id,
                Name        = badName,
                Description = badName
            };

            var responseMetaDataAfterEdit = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST);

            Assert.That(responseMetaDataAfterEdit.Status, Is.EqualTo(HttpStatusCode.BadRequest));
        }
        public async Task EditMetadata()
        {
            string url = ApiPaths.ALGO_STORE_METADATA;

            MetaDataResponseDTO temporaryResponseDTO = DataManager.getMetadataForEdit();
            MetaDataEditDTO     editMetaData         = new MetaDataEditDTO()
            {
                Id          = temporaryResponseDTO.Id,
                Name        = Helpers.RandomString(9),
                Description = Helpers.RandomString(9)
            };

            temporaryResponseDTO.Name        = editMetaData.Name;
            temporaryResponseDTO.Description = editMetaData.Description;

            var responseMetaDataAfterEdit = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST);

            Assert.That(responseMetaDataAfterEdit.Status, Is.EqualTo(HttpStatusCode.OK));
            MetaDataResponseDTO responceMetaDataAfterEdit = JsonUtils.DeserializeJson <MetaDataResponseDTO>(responseMetaDataAfterEdit.ResponseJson);

            Assert.AreEqual(responceMetaDataAfterEdit.Name, editMetaData.Name);
            Assert.AreEqual(responceMetaDataAfterEdit.Description, editMetaData.Description);
            Assert.NotNull(responceMetaDataAfterEdit.Date);
            Assert.NotNull(responceMetaDataAfterEdit.Id);
            Assert.Null(responceMetaDataAfterEdit.Status);


            MetaDataEntity metaDataEntity = await MetaDataRepository.TryGetAsync(t => t.Id == responceMetaDataAfterEdit.Id) as MetaDataEntity;

            Assert.NotNull(metaDataEntity);
            Assert.AreEqual(metaDataEntity.Id, responceMetaDataAfterEdit.Id);
            Assert.AreEqual(metaDataEntity.Name, responceMetaDataAfterEdit.Name);
            Assert.AreEqual(metaDataEntity.Description, responceMetaDataAfterEdit.Description);
        }
        public async Task EditMetadataBadRequest(string badName)
        {
            string url = ApiPaths.ALGO_STORE_METADATA;

            MetaDataResponseDTO temporaryResponseDTO = DataManager.getMetadataForEdit();
            MetaDataEditDTO     editMetaData         = new MetaDataEditDTO()
            {
                Id          = temporaryResponseDTO.Id,
                Name        = badName,
                Description = badName
            };

            var responseMetaDataAfterEdit = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST);

            Assert.That(responseMetaDataAfterEdit.Status, Is.EqualTo(HttpStatusCode.BadRequest));
        }