private static void ReadAndVerify(Enums.ResourceType resourceType, string fieldAlias, string id, string expectedValue)
        {
            ReadResponseData <XmlResource> result = ResourceHelper.ReadResourceById(resourceType, fieldAlias, id);

            Assert.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceType));

            Assert.That(result.Items[0].DictionaryValues[fieldAlias], MustBe.EqualTo(expectedValue), "The field value is not written correctly!");
        }
예제 #2
0
        private void PrepareData(Enums.ResourceType resourceType, string fieldAlias, string updateId, long fieldValue)
        {
            XmlResource resource = ResourceHelper.CreateUpdatedResource(resourceType, updateId, fieldAlias, fieldValue);
            string      id       = ResourceHelper.WriteResource(resource, null);

            //Verify result
            Assume.That(id, MustBe.Not.Null.And.Not.Empty, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assume.That(id, MustBe.EqualTo(updateId), string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
        }
        public void TestUpdateSingleItem(Enums.ResourceType resourceType, PhaseDateInput phaseDateType, PhaseOptionInput phaseOptionType, int expectedCode, int index)
        {
            phaseDictionary = PhaseFieldHelper.InitPhaseList(phaseSearcher);
            var resource = PhaseFieldHelper.GetUpdatedResourcePhaseField(resourceType, phaseDateType, phaseOptionType, index,
                                                                         phaseSearcher, phaseEntryReader, GetPhaseOrderBySort(resourceType), phaseDictionary, records);
            string result = ResourceHelper.WriteResource(resource, null);

            Assert.That(result, MustBe.EqualTo(records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString()), string.Format("Cannot update phase for {0}", resourceType));
        }
예제 #4
0
        /// <summary>
        /// Send and verify a post request failed
        /// </summary>
        /// <param name="apiUrl">Url of api</param>
        /// <param name="parameters">Parameters</param>
        public static void SendPostRequestApiError(string apiUrl, Dictionary <string, object> parameters)
        {
            Handler handler = PublicApiAdapter.CreateAdapterForDefaultConnection().Write(nameof(Partition), null, parameters);

            Assert.That(handler, MustBe.Not.Null, "Cannot send a request to PublicAPI");
            Assert.That(handler.HttpCode, MustBe.EqualTo(HttpStatusCode.OK), "Cannot send a request to PublicAPI");
            ErrorCode errorCode = XmlHelper.ParseXMLString <ErrorCode>(handler.RawContent);

            Assert.That(errorCode, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.ResourceNotExist), Enums.Message.WRONG_ERROR_CODE);
        }
        public void TestReadGeneralFieldSettingValidation(Enums.ResourceType resourceType, ReadInvalidInputTestData.ItemState itemState, string fieldName, FieldProperty fieldProperty, object val)
        {
            var parameters = new Dictionary <string, object>()
            {
                { DeletedDataFields.Partition, AuthenticationInfoProvider.Current.DefaultPartition },
                { DeletedDataFields.ItemState, itemState.ToLowerString() },
                { DeletedDataFields.Condition, $"{resourceType.ToResourceName()}.{fieldName}:eq={fieldValues[fieldName]}" }
            };

            var result = PublicApiAdapter.CreateAdapterForDefaultConnection().ReadSuccess(resourceType.ToString(), parameters);

            Assert.That(result.Code, MustBe.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);
        }
예제 #6
0
        /// <summary>
        /// Send a request to update a single resource
        /// </summary>
        /// <param name="resourceType"></param>
        /// <param name="fieldAlias"></param>
        /// <param name="fieldValue"></param>
        /// <param name="expectedCode"></param>
        /// <param name="records"></param>
        public static void UpdateSingleItem(Enums.ResourceType resourceType, string fieldAlias, Func <int, object> getFieldValue,
                                            HrbcRecordCreator records, Action <object> verifyActualValue = null, bool idRelatedFieldCreatedAutomatically = false, int index = 0,
                                            HrbcRecordCreator referenceRecords = null)
        {
            XmlResource resource = ResourceHelper.CreateUpdatedResource(resourceType, records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString(),
                                                                        fieldAlias, getFieldValue(index), idRelatedFieldCreatedAutomatically, referenceRecords, index);
            string id = ResourceHelper.WriteResource(resource, null);

            //Verify result
            Assert.That(id, MustBe.Not.Null.And.Not.Empty, string.Format(Enums.Message.UPDATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assert.That(id, MustBe.EqualTo(records.Data[$"{resourceType.ToPrivateEnum()}{index}"].Id.ToString()));
            ReadAndVerify(resourceType, fieldAlias, id, verifyActualValue);
        }
예제 #7
0
        public void TestWriteSingleItem()
        {
            Field field = new Field()
            {
                Id = "-1", Alias = $"{ResourceId.Client}.U_123456789", Name = "Test field", Type = "1"
            };
            Dictionary <string, object> urlParameter = new Dictionary <string, object>()
            {
                ["partition"] = AuthenticationInfoProvider.Current.DefaultPartition
            };
            Handler handler = PublicApiAdapter.CreateAdapterForDefaultConnection().Write <Field>(field, AuthenticationInfoProvider.Current.DefaultPartition);

            Assert.That(handler, MustBe.Not.Null, "Cannot send a request to PublicAPI");
            Assert.That(handler.HttpCode, MustBe.EqualTo(HttpStatusCode.OK), "Cannot send a request to PublicAPI");
            ErrorCode errorCode = XmlHelper.ParseXMLString <ErrorCode>(handler.RawContent);

            Assert.That(errorCode, MustBe.MatchingErrorCode(Enums.PublicAPIResultCode.ResourceNotExist), Enums.Message.WRONG_ERROR_CODE);
        }