public void GetOrAddShouldReturnExistingValue()
        {
            // arrange
            var expected = new object();
            var target = new Dictionary<string, object>() { { "Test", expected } };
            
            // act
            var actual = target.GetOrAdd( "Test", () => new object() );

            // assert
            Assert.Equal( expected, actual );
            Assert.Equal( 1, target.Count );
            Assert.True( target.ContainsKey( "Test" ) );
        }
        public void GetOrAddShouldInsertAndReturnNewItemIntoDictionary()
        {
            // arrange
            var expected = new object();
            var target = new Dictionary<string, object>();

            // act
            var actual = target.GetOrAdd( "Test", () => expected );

            // assert
            Assert.Equal( expected, actual );
            Assert.Equal( 1, target.Count );
            Assert.True( target.ContainsKey( "Test" ) );
        }
        private IEnumerable<SelectGroupItem> BuildGroupList()
        {
            if (Items == null)
                return Enumerable.Empty<SelectGroupItem>();

            if (Items is IEnumerable<SelectGroupItem>)
                return Items as IEnumerable<SelectGroupItem>;

            var groups = new Dictionary<string, SelectGroupItem>();

            foreach (var item in Items)
            {
                var selectListItem = CreateSelectItem(item);

                var group = LateBinder.GetProperty(item, DataGroupField);
                var groupString = Convert.ToString(group);

                var groupItem = groups.GetOrAdd(groupString, k => new SelectGroupItem { Label = k });
                groupItem.Items.Add(selectListItem);
            }

            return groups.Values;
        }