diff options
author | Marek Safar <marek.safar@gmail.com> | 2014-01-04 12:51:42 +0400 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2014-01-04 12:51:42 +0400 |
commit | 996a249ff296edb2d0872045e24b6c47e2dfeec9 (patch) | |
tree | a02e49451f1914d99fb0890190861ee8038a9330 /mcs/class | |
parent | fefb5f9b7b8a205ee33393e43847b68e626708ad (diff) | |
parent | 57c18def14b4acb3af02a9bc3232ea3004ab42db (diff) |
Merge pull request #859 from antoniusriha/groupDescription
Implement GroupDescription based on moonlight implementation
Diffstat (limited to 'mcs/class')
6 files changed, 78 insertions, 3 deletions
diff --git a/mcs/class/WindowsBase/System.ComponentModel/GroupDescription.cs b/mcs/class/WindowsBase/System.ComponentModel/GroupDescription.cs index ed9d824c339..edc1a624b2c 100644 --- a/mcs/class/WindowsBase/System.ComponentModel/GroupDescription.cs +++ b/mcs/class/WindowsBase/System.ComponentModel/GroupDescription.cs @@ -31,12 +31,15 @@ namespace System.ComponentModel { public abstract class GroupDescription : INotifyPropertyChanged { + readonly ObservableCollection<object> groupNames; + protected GroupDescription () { + groupNames = new ObservableCollection<object> (); } public ObservableCollection<object> GroupNames { - get { throw new NotImplementedException (); } + get { return groupNames; } } event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged { @@ -48,7 +51,7 @@ namespace System.ComponentModel { public virtual bool NamesMatch (object groupName, object itemName) { - throw new NotImplementedException (); + return Equals (groupName, itemName); } protected virtual void OnPropertyChanged (PropertyChangedEventArgs e) @@ -60,7 +63,7 @@ namespace System.ComponentModel { [EditorBrowsable (EditorBrowsableState.Never)] public bool ShouldSerializeGroupNames () { - throw new NotImplementedException (); + return GroupNames.Count != 0; } public abstract object GroupNameFromItem (object item, int level, CultureInfo culture); diff --git a/mcs/class/WindowsBase/Test/System.ComponentModel/GroupDescriptionTest.cs b/mcs/class/WindowsBase/Test/System.ComponentModel/GroupDescriptionTest.cs new file mode 100644 index 00000000000..037e0394ec5 --- /dev/null +++ b/mcs/class/WindowsBase/Test/System.ComponentModel/GroupDescriptionTest.cs @@ -0,0 +1,68 @@ +// +// GroupDescriptionTest.cs +// +// Author: +// Antonius Riha <antoniusriha@gmail.com> +// +// Copyright (c) 2014 Antonius Riha +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.ComponentModel; +using System.Globalization; +using NUnit.Framework; + +namespace MonoTests.System.ComponentModel +{ + [TestFixture] + public class GroupDescriptionTest + { + [Test] + public void NamesMatch () + { + var gd = new ConcreteGroupDescription (); + var obj = new object (); + Assert.IsTrue (gd.NamesMatch (obj, obj), "A1"); + Assert.IsFalse (gd.NamesMatch (new object (), new object ()), "A2"); + } + + [Test] + public void ShouldSerializeGroupNames () + { + var g = new ConcreteGroupDescription (); + g.GroupNames.Add ("name"); + Assert.IsTrue (g.ShouldSerializeGroupNames (), "#A1"); + } + + [Test] + public void ShouldSerializeGroupNamesEmpty () + { + var g = new ConcreteGroupDescription (); + Assert.IsFalse (g.ShouldSerializeGroupNames (), "#A1"); + } + + class ConcreteGroupDescription : GroupDescription + { + public override object GroupNameFromItem (object item, int level, CultureInfo culture) + { + throw new NotSupportedException (); + } + } + } +} diff --git a/mcs/class/WindowsBase/WindowsBase-tests-net_2_0.csproj b/mcs/class/WindowsBase/WindowsBase-tests-net_2_0.csproj index 0ed7508a9e7..86ea26d3e9f 100644 --- a/mcs/class/WindowsBase/WindowsBase-tests-net_2_0.csproj +++ b/mcs/class/WindowsBase/WindowsBase-tests-net_2_0.csproj @@ -49,6 +49,7 @@ <Compile Include="Test\System.Collections.Specialized\CollectionChangedEventValidators.cs" />
<Compile Include="Test\System.Collections.Specialized\NotifyCollectionChangedEventArgsTest.cs" />
<Compile Include="Test\System.ComponentModel\CurrentChangingEventArgsTest.cs" />
+ <Compile Include="Test\System.ComponentModel\GroupDescriptionTest.cs" />
<Compile Include="Test\System.ComponentModel\PropertyFilterAttributeTest.cs" />
<Compile Include="Test\System.ComponentModel\SortDescriptionCollectionTest.cs" />
<Compile Include="Test\System.ComponentModel\SortDescriptionTest.cs" />
diff --git a/mcs/class/WindowsBase/WindowsBase-tests-net_4_0.csproj b/mcs/class/WindowsBase/WindowsBase-tests-net_4_0.csproj index 1bc72234ac8..8e125454ae8 100644 --- a/mcs/class/WindowsBase/WindowsBase-tests-net_4_0.csproj +++ b/mcs/class/WindowsBase/WindowsBase-tests-net_4_0.csproj @@ -49,6 +49,7 @@ <Compile Include="Test\System.Collections.Specialized\CollectionChangedEventValidators.cs" />
<Compile Include="Test\System.Collections.Specialized\NotifyCollectionChangedEventArgsTest.cs" />
<Compile Include="Test\System.ComponentModel\CurrentChangingEventArgsTest.cs" />
+ <Compile Include="Test\System.ComponentModel\GroupDescriptionTest.cs" />
<Compile Include="Test\System.ComponentModel\PropertyFilterAttributeTest.cs" />
<Compile Include="Test\System.ComponentModel\SortDescriptionCollectionTest.cs" />
<Compile Include="Test\System.ComponentModel\SortDescriptionTest.cs" />
diff --git a/mcs/class/WindowsBase/WindowsBase-tests-net_4_5.csproj b/mcs/class/WindowsBase/WindowsBase-tests-net_4_5.csproj index 589bc53ce45..f194fb2369a 100644 --- a/mcs/class/WindowsBase/WindowsBase-tests-net_4_5.csproj +++ b/mcs/class/WindowsBase/WindowsBase-tests-net_4_5.csproj @@ -49,6 +49,7 @@ <Compile Include="Test\System.Collections.Specialized\CollectionChangedEventValidators.cs" />
<Compile Include="Test\System.Collections.Specialized\NotifyCollectionChangedEventArgsTest.cs" />
<Compile Include="Test\System.ComponentModel\CurrentChangingEventArgsTest.cs" />
+ <Compile Include="Test\System.ComponentModel\GroupDescriptionTest.cs" />
<Compile Include="Test\System.ComponentModel\PropertyFilterAttributeTest.cs" />
<Compile Include="Test\System.ComponentModel\SortDescriptionCollectionTest.cs" />
<Compile Include="Test\System.ComponentModel\SortDescriptionTest.cs" />
diff --git a/mcs/class/WindowsBase/WindowsBase_test.dll.sources b/mcs/class/WindowsBase/WindowsBase_test.dll.sources index 437fef32ef8..23dde059fc7 100644 --- a/mcs/class/WindowsBase/WindowsBase_test.dll.sources +++ b/mcs/class/WindowsBase/WindowsBase_test.dll.sources @@ -3,6 +3,7 @@ System.Collections.ObjectModel/ReadOnlyObservableCollectionTest.cs System.Collections.Specialized/NotifyCollectionChangedEventArgsTest.cs System.Collections.Specialized/CollectionChangedEventValidators.cs System.ComponentModel/CurrentChangingEventArgsTest.cs +System.ComponentModel/GroupDescriptionTest.cs System.ComponentModel/PropertyFilterAttributeTest.cs System.ComponentModel/SortDescriptionCollectionTest.cs System.ComponentModel/SortDescriptionTest.cs |