Esempio n. 1
0
        public void TestValidDuplicateChecks(ResourceId resourceId, HasDuplicate duplicate)
        {
            var handler = new DefaultManager();
            var request = new Dictionary <string, object>
            {
                [HasDuplicateParams.Resource.GetEnumStringValue()] = resourceId.ToResourceName()
            };

            MappingData[duplicate](resourceId, request);
            CreateDuplicateTask(resourceId, request[HasDuplicateParams.ResourceId.GetEnumStringValue()].ToString());
            Thread.Sleep(5000);
            var response = handler.Send <Dictionary <string, int> >(DuplicateCheckEndpoint, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Duplicate checks is failed");

            //Verify
            if (duplicate == HasDuplicate.Empty)
            {
                PrAssert.That(response.Result, PrIs.Null.Or.Empty, "Duplicate value is empty.");
            }
            else
            {
                var ids = request[HasDuplicateParams.ResourceId.GetEnumStringValue()].ToString().Split(",");
                for (var i = 0; i < ids.Count(); i++)
                {
                    PrAssert.That(response.Result[ids[i]], PrIs.GreaterThan(0), "There is no any duplicate.");
                }
            }
        }
Esempio n. 2
0
        public void TestValidDuplicateChecksOtherResources(ResourceId resourceId)
        {
            var handler = new DefaultManager();
            var request = new Dictionary <string, object>
            {
                [HasDuplicateParams.ResourceId.GetEnumStringValue()] = RecordsCreator.Data[$"{resourceId}0"].Id.ToString(),
                [HasDuplicateParams.Resource.GetEnumStringValue()]   = resourceId.ToResourceName()
            };
            var response = handler.Send <Dictionary <string, int> >(DuplicateCheckEndpoint, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Duplicate checks is failed");
            PrAssert.That(response.Result, PrIs.Null.Or.Empty, "There is still a duplicate.");
        }
Esempio n. 3
0
        /// <summary>
        /// Create a duplicate for array string of record ids
        /// </summary>
        /// <param name="resourceId">resourceId</param>
        /// <param name="arrStrRecordIds">Array record ids</param>
        /// <returns>Duplicate Id</returns>
        public static int CreateHasDuplicate(ResourceId resourceId, string arrStrRecordIds)
        {
            var handler = new DefaultManager();
            var request = new Dictionary <string, object>
            {
                [HasDuplicateParams.ResourceId.GetEnumStringValue()] = arrStrRecordIds,
                [HasDuplicateParams.Resource.GetEnumStringValue()]   = resourceId.ToResourceName()
            };

            CreateDuplicateTask(resourceId, request[HasDuplicateParams.ResourceId.GetEnumStringValue()].ToString());
            Thread.Sleep(5000);
            var response = handler.Send <Dictionary <string, int> >(DuplicateCheckEndpoint, JsonConvert.SerializeObject(request), HttpMethod.POST);

            PrAssert.That(response, PrIs.SuccessfulResponse().And.HttpCode(System.Net.HttpStatusCode.OK), "Duplicate checks is failed");
            return(response.Result[arrStrRecordIds.Split(",")[0]]);
        }