Example #1
0
        public static void UpdateListItem(Enums.ResourceType resourceType, string fieldAlias, ZeroScaleValidInput valueType, HrbcRecordCreator records, HrbcRecordDelete cleaner)
        {
            var fieldValue    = WriteZeroScaleValidInput.GetDataInput(valueType).Input;
            var expectedValue = WriteZeroScaleValidInput.GetDataInput(valueType).Expected;

            IEnumerable <XmlResource> resourceList = new List <XmlResource>
            {
                ResourceHelper.CreateResourceInstance(records, resourceType, 0),
                ResourceHelper.CreateResourceInstance(records, resourceType, 1)
            };

            List <WriteResultItem> ids = ResourceHelper.WriteResources(resourceType, resourceList, cleaner);

            Assume.That(ids, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            Assume.That(ids.Select(t => t.Code), Is.All.EqualTo(0), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));

            resourceList = ids.Select(item =>
            {
                return(ResourceHelper.CreateUpdatedResource(resourceType, item.Id, fieldAlias, fieldValue));
            });

            List <WriteResultItem> result = ResourceHelper.WriteResources(Enums.ResourceType.Activity, resourceList, cleaner);

            Assert.That(result, Is.Not.Null, "The response data is incorrect!");
            Assert.That(result.Count, Is.EqualTo(resourceList.Count()), "The response data is incorrect!");
            foreach (var item in result)
            {
                Assert.That(item.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);
                Assert.That(item.Id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
                ReadAndVerifyData(resourceType, item.Id, fieldAlias, expectedValue.ToString());
            }
        }
Example #2
0
        public static void CreateSingleItem(Enums.ResourceType resourceType, string fieldAlias, ZeroScaleValidInput valueType, HrbcRecordCreator records, HrbcRecordDelete cleaner)
        {
            var fieldValue    = WriteZeroScaleValidInput.GetDataInput(valueType).Input;
            var expectedValue = WriteZeroScaleValidInput.GetDataInput(valueType).Expected;

            XmlResource resource = ResourceHelper.CreateResourceInstance(records, resourceType);

            resource.DictionaryValues[fieldAlias] = fieldValue;

            string id = ResourceHelper.WriteResource(resource, cleaner);

            Assert.That(id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
            ReadAndVerifyData(resourceType, id, fieldAlias, expectedValue.ToString());
        }
Example #3
0
        public static void CreateListItem(Enums.ResourceType resourceType, string fieldAlias, ZeroScaleValidInput valueType, HrbcRecordCreator records, HrbcRecordDelete cleaner)
        {
            var fieldValue    = WriteZeroScaleValidInput.GetDataInput(valueType).Input;
            var expectedValue = WriteZeroScaleValidInput.GetDataInput(valueType).Expected;

            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var resource = ResourceHelper.CreateResourceInstance(records, resourceType, depKey);
                resource.DictionaryValues[fieldAlias] = fieldValue;
                return(resource);
            }).ToList();

            List <WriteResultItem> result = ResourceHelper.WriteResources(resourceType, resourceList, cleaner);

            Assert.That(result, Is.Not.Null, "The response data is incorrect!");
            Assert.That(result.Count, Is.EqualTo(resourceList.Count()), "The response data is incorrect!");
            foreach (var item in result)
            {
                Assert.That(item.Code, Is.EqualTo(Enums.PublicAPIResultCode.Success), Enums.Message.WRONG_ERROR_CODE);
                Assert.That(item.Id, Is.Not.Null.And.Not.Empty, string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
                ReadAndVerifyData(resourceType, item.Id, fieldAlias, expectedValue.ToString());
            }
        }