/// <summary> /// Create the key/value dictionary of global identifier and string. /// </summary> /// <param name="dropDownFirstItemType">Type of the drop down first item.</param> /// <returns> /// The Dictionary. /// </returns> public static Dictionary <Guid, string> CreateKeyValueDictionaryOfGuidString(DropDownFirstItemType dropDownFirstItemType = DropDownFirstItemType.None) { var dictionary = new Dictionary <Guid, string>(); switch (dropDownFirstItemType) { case DropDownFirstItemType.None: break; case DropDownFirstItemType.Blank: dictionary.Add( DropDownFirstItemTypeHelper.GetEnumGuid(DropDownFirstItemType.Blank), string.Empty); break; case DropDownFirstItemType.PleaseSelect: dictionary.Add( DropDownFirstItemTypeHelper.GetEnumGuid(DropDownFirstItemType.PleaseSelect), EnumResources.DropDownFirstItemTypePleaseSelect); break; case DropDownFirstItemType.IncludeAll: dictionary.Add( DropDownFirstItemTypeHelper.GetEnumGuid(DropDownFirstItemType.IncludeAll), EnumResources.DropDownFirstItemTypeIncludeAll); break; default: throw new SwitchCaseDefaultException(dropDownFirstItemType); } return(dictionary); }
public void GetEnumGuid(string expected, DropDownFirstItemType input) { // Act var actual = DropDownFirstItemTypeHelper.GetEnumGuid(input); // Assert Assert.Equal(expected, actual.ToString().ToUpperInvariant()); }
public void GetItemFromEnumGuid(DropDownFirstItemType expected, string input) { // Arrange var guid = Guid.Parse(input); // Act var actual = DropDownFirstItemTypeHelper.GetItemFromEnumGuid(guid); // Assert Assert.Equal(expected, actual); }
public void EnsureFirstItemType(int expectedCount, string expectedFirstItem, DropDownFirstItemType input) { // Arrange var list = new List <string> { "John", "Bob", }; // Act var actual = DropDownFirstItemTypeHelper.EnsureFirstItemType(list, input); // Assert actual.Should().HaveCount(expectedCount); Assert.Equal(expectedFirstItem, actual.First()); }
/// <summary> /// Create the key/value data table of global identifier and string. /// </summary> /// <param name="dropDownFirstItemType">Type of the drop down first item.</param> /// <returns> /// The <see cref="DataTable" />. /// </returns> public static DataTable CreateKeyValueDataTableOfGuidString(DropDownFirstItemType dropDownFirstItemType = DropDownFirstItemType.None) { var dt = new DataTable { Locale = CultureInfo.InvariantCulture, }; dt.Columns.Add("key", typeof(Guid)); dt.Columns.Add("value", typeof(string)); dt.PrimaryKey = new[] { dt.Columns["key"] }; dt.AcceptChanges(); DataRow dr; switch (dropDownFirstItemType) { case DropDownFirstItemType.None: break; case DropDownFirstItemType.Blank: dr = dt.NewRow(); dr["key"] = DropDownFirstItemTypeHelper.GetEnumGuid(DropDownFirstItemType.Blank); dr["value"] = string.Empty; dt.Rows.Add(dr); break; case DropDownFirstItemType.PleaseSelect: dr = dt.NewRow(); dr["key"] = DropDownFirstItemTypeHelper.GetEnumGuid(DropDownFirstItemType.PleaseSelect); dr["value"] = EnumResources.DropDownFirstItemTypePleaseSelect; dt.Rows.Add(dr); break; case DropDownFirstItemType.IncludeAll: dr = dt.NewRow(); dr["key"] = DropDownFirstItemTypeHelper.GetEnumGuid(DropDownFirstItemType.IncludeAll); dr["value"] = EnumResources.DropDownFirstItemTypeIncludeAll; dt.Rows.Add(dr); break; default: throw new SwitchCaseDefaultException(dropDownFirstItemType); } return(dt); }