Ejemplo n.º 1
0
        public void TestCreateListItem(Enums.ResourceType resourceType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                return(PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey));
            }).ToList();

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Ejemplo n.º 2
0
        public void TestCreateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                Phase phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey);
                phase.Memo  = Util.GetRandomText(textType, stringLength[lengthType]);
                return(phase);
            }).ToList();

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Ejemplo n.º 3
0
        public void TestUpdateListItem(Enums.ResourceType resourceType, LengthType lengthType, Enums.TextType textType)
        {
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = new Phase
                {
                    Id   = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id,
                    Memo = Util.GetRandomText(textType, stringLength[lengthType]),
                };
                return(phase);
            });

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot update phase memo for {0}", resourceType));
        }
Ejemplo n.º 4
0
        public void TestCreateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType)
        {
            string fieldValue = FieldValueMapper.ValidInputMapper[valueType];

            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = PhaseHelper.CreatePhaseInstance(creatingRequestRecords, resourceType, depKey);
                phase.DictionaryValues[fieldName] = fieldValue;

                return(phase);
            }).ToList();

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Ejemplo n.º 5
0
        public void TestListItem(Enums.ResourceType resourceType, BulkWriteInputType firstItemType, BulkWriteInputType secondItemType)
        {
            var resourceList = new List <Phase>()
            {
                CreateBulkWritePhaseInstance(resourceType, firstItemType, 0),
                CreateBulkWritePhaseInstance(resourceType, secondItemType, 1),
            };

            //Write data
            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            //Verify result
            Assert.That(result, Is.Not.Null, "Create records operation failed. Response is null or cannot be parsed.");
            Assert.That(result.Count, Is.EqualTo(resourceList.Count), "Create records operation failed. Number of successfully inserted resources is not same as the number of records we intended to insert");
            BulkWriteHelper.VerifyBulkWriteResultItem(firstItemType, result[0]);
            BulkWriteHelper.VerifyBulkWriteResultItem(secondItemType, result[1]);
        }
Ejemplo n.º 6
0
        public void TestUpdateListItem(Enums.ResourceType resourceType, string fieldName, WriteValidInput valueType)
        {
            string fieldValue = FieldValueMapper.ValidInputMapper[valueType];
            var    resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = new Phase
                {
                    Id = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id,
                };
                phase.DictionaryValues[fieldName] = fieldValue;
                return(phase);
            });

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Ejemplo n.º 7
0
        public void TestUpdateListItem(Enums.ResourceType resourceType)
        {
            var resourcePhase = PhaseSearcher.Data.Options.Where(op => op.Alias == $"Option.P_{resourceType.ToResourceName()}Phase").SingleOrDefault();
            var resourceList = new[] { 0, 1 }.Select(depKey =>
            {
                var phase = new Phase
                {
                    Id          = phaseReader.Data[$"{resourceType.ToPrivateEnum()}{depKey}"].FirstOrDefault().Id,
                    PhaseObject = new Option()
                    {
                        ActualXMLTag = resourcePhase.Children.FirstOrDefault().Alias
                    },
                };
                return(phase);
            });

            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(2), string.Format("Cannot create phase for {0}", resourceType));
        }
Ejemplo n.º 8
0
        private void WriteAndVerify(Enums.ResourceType resourceType, int recordNumber, bool isUpdate = false)
        {
            List <Phase> resourceList = new List <Phase>();
            Phase        phase        = new Phase();

            for (int i = 0; i < recordNumber; i++)
            {
                if (isUpdate)
                {
                    phase = new Phase {
                        Id = phaseEntryReader.Data[$"{resourceType.ToPrivateEnum()}{i}"].First().Id
                    };
                }
                else
                {
                    phase = PhaseHelper.CreatePhaseInstance(creatingRecords, resourceType, i);
                }
                resourceList.Add(phase);
            }
            List <WriteResultItem> result = PhaseHelper.WritePhases(resourceList);

            Assert.That(result, MustBe.SuccessfullyWritten(resourceList.Count), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, resourceType));
        }