Beispiel #1
0
        /// <summary>
        /// Create a phase
        /// </summary>
        /// <param name="resourceType">Resource type</param>
        /// <param name="resourceId">Resource id</param>
        /// <returns>Phase id</returns>
        public static string CreatePhase(Enums.ResourceType resourceType, string resourceId)
        {
            var    phase   = FieldHelper.CreatePhaseInstance(resourceType, resourceId);
            string phaseId = PublicApiAdapter.CreateAdapterForDefaultConnection().WriteSuccess(phase, null);

            int  id     = -1;
            bool parsed = Int32.TryParse(phaseId, out id);

            Assume.That(parsed, "The parsing of phase id is wrong!");
            Assume.That(id, Is.GreaterThan(0), string.Format(Enums.Message.CREATE_RESOURCE_ENTRY_FAILED, "Phase"));
            return(phaseId);
        }
        /// <summary>
        /// Read and verify datetime field value by phase
        /// </summary>
        /// <param name="resourceName">Resource Name</param>
        /// <param name="id">Resource Id</param>
        /// <param name="fieldAlias">Field Alias</param>
        /// <returns>empty</returns>
        public static void ReadAndVerifyAutoDesignatedDateForPhase(Enums.ResourceType resourceType, string id, string fieldName)
        {
            string resourceName = resourceType.ToResourceName();
            ReadResponseData <XmlResource> result = FieldHelper.ReadPhase(resourceType, id, new List <string> {
                fieldName
            });

            Assume.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceName));
            DateTime tempDate;

            Assert.That(DateTime.TryParse(result.Items[0].DictionaryValues[fieldName].ToString(), out tempDate), ErrorMessage);
        }
        /// <summary>
        /// Read and verify datetime field value by phase
        /// </summary>
        /// <param name="resourceName">Resource Name</param>
        /// <param name="id">Resource Id</param>
        /// <param name="fieldAlias">Field Alias</param>
        /// <returns>empty</returns>
        public static void ReadAndVerifyNoValidationDateForPhase(Enums.ResourceType resourceType, string id, string fieldAlias)
        {
            string resourceName          = resourceType.ToResourceName();
            string registrationDateAlias = SystemTypeField.RegistrationDate.Substring(2);
            string updateDateAlias       = SystemTypeField.UpdateDate.Substring(2);

            ReadResponseData <XmlResource> result = FieldHelper.ReadPhase(resourceType, id, new List <string> {
                registrationDateAlias, updateDateAlias
            });

            Assume.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceName));
            VerifyLessOrGreaterThanDateTime(result, fieldAlias, registrationDateAlias, updateDateAlias);
        }
Beispiel #4
0
 /// <summary>
 /// Create a phase instance
 /// </summary>
 /// <param name="resourceType">Resource type</param>
 /// <param name="id">Id</param>
 /// <returns>Phase</returns>
 public static Phase CreatePhaseInstance(Enums.ResourceType resourceType, string id)
 {
     return(new Phase
     {
         Id = "-1",
         Resource = ((int)resourceType).ToString(),
         ResourceId = id,
         PhaseObject = new Option()
         {
             ActualXMLTag = FieldHelper.GetOptionPhaseName(resourceType)
         },
         Memo = "Memo Test",
     });
 }
        /// <summary>
        /// Read and verify datetime field value by phase
        /// </summary>
        /// <param name="resourceName">Resource Name</param>
        /// <param name="id">Resource Id</param>
        /// <param name="fieldAlias">Field Alias</param>
        /// <param name="value">Field Value</param>
        /// <returns>empty</returns>
        public static void ReadAndVerifyDateForPhase(Enums.ResourceType resourceType, string id, string fieldName, string value)
        {
            string resourceName = resourceType.ToResourceName();
            ReadResponseData <XmlResource> result = FieldHelper.ReadPhase(resourceType, id, new List <string> {
                fieldName
            });

            Assume.That(result, MustBe.ReadSuccess(1), string.Format(Enums.Message.READ_RESOURCE_FAILED, resourceName));

            //Year 0000 is invalid date in C# so could not convert to datetime
            if (value.Contains(Year0000))
            {
                Assert.That(result.Items[0].DictionaryValues[fieldName].ToString(), Is.EqualTo(value), ErrorMessage);
            }
            else
            {
                Assert.That(Convert.ToDateTime(result.Items[0].DictionaryValues[fieldName]), Is.EqualTo(Convert.ToDateTime(value)), ErrorMessage);
            }
        }