public void ShouldProcessSimpleBugzillaCustomField()
		{
			const string cfName = "cf name";
			const string cfValue = "cf value";

			var field = new custom_field {cf_name = cfName, cf_value = cfValue};

			var info = new CustomFieldInfo(field);

			info.Name.Should(Be.EqualTo(cfName));
			info.Values.Should(Be.EquivalentTo(new[] {cfValue}));
		}
		public void ShouldProcessCollectionBugzillaCustomField()
		{
			const string cfName = "cf name";
			const string cfValue1 = "cf value1";
			const string cfValue2 = "cf value2";

			var field = new custom_field { cf_name = cfName, cf_type = "Multiple-Selection Box", cf_values = new cf_values{cf_valueCollection = new cf_valueCollection {cfValue1, cfValue2}}};

			var info = new CustomFieldInfo(field);

			info.Name.Should(Be.EqualTo(cfName));
			info.Values.Should(Be.EquivalentTo(new[] { cfValue1, cfValue2 }));
		}
		public void Insert(int index, custom_field obj)
		{
			base.Insert(index, obj);
		}
		public void Remove(custom_field obj)
		{
			base.Remove(obj);
		}
		private static IEnumerable<string> GetCustomFieldValue(custom_field bugzillaCustomField)
		{
			return CustomFieldHasValue(bugzillaCustomField.cf_type, bugzillaCustomField.cf_value) 
				? new[] {bugzillaCustomField.cf_value} 
				: Enumerable.Empty<string>();
		}
		public custom_field Add(custom_field obj)
		{
			base.Add(obj);
			return obj;
		}
		private static bool IsCollection(custom_field bugzillaCustomField)
		{
			return "Multiple-Selection Box".Equals(bugzillaCustomField.cf_type, StringComparison.OrdinalIgnoreCase);
		}
		private static IEnumerable<string> GetCustomFieldCollectionValue(custom_field field)
		{
			var values = field.cf_values.cf_valueCollection.Cast<string>().Where(ValueIsNotEmpty).ToList();

			return values.Count > 0 ? values : Enumerable.Empty<string>();
		}
		private static IEnumerable<string> GetBugzillaCustomFieldValues(custom_field bugzillaCustomField)
		{
			return IsCollection(bugzillaCustomField) 
				? GetCustomFieldCollectionValue(bugzillaCustomField) 
				: GetCustomFieldValue(bugzillaCustomField);
		}
		public CustomFieldInfo(custom_field source)
		{
			Name = source.cf_name;
			Description = source.cf_description;
			Values = GetBugzillaCustomFieldValues(source);
		}
Esempio n. 11
0
 public void Remove(custom_field obj)
 {
     base.Remove(obj);
 }
Esempio n. 12
0
 public void Insert(int index, custom_field obj)
 {
     base.Insert(index, obj);
 }
Esempio n. 13
0
 public custom_field Add(custom_field obj)
 {
     base.Add(obj);
     return(obj);
 }