コード例 #1
0
ファイル: DataFactory.cs プロジェクト: atc-net/atc
        /// <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);
        }
コード例 #2
0
        public void GetEnumGuid(string expected, DropDownFirstItemType input)
        {
            // Act
            var actual = DropDownFirstItemTypeHelper.GetEnumGuid(input);

            // Assert
            Assert.Equal(expected, actual.ToString().ToUpperInvariant());
        }
コード例 #3
0
        public void GetItemFromEnumGuid(DropDownFirstItemType expected, string input)
        {
            // Arrange
            var guid = Guid.Parse(input);

            // Act
            var actual = DropDownFirstItemTypeHelper.GetItemFromEnumGuid(guid);

            // Assert
            Assert.Equal(expected, actual);
        }
コード例 #4
0
        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());
        }
コード例 #5
0
ファイル: DataFactory.cs プロジェクト: atc-net/atc
        /// <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);
        }