Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/shortcuts@4598 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts^2
24 changed files with 200 additions and 676 deletions
@ -1,49 +0,0 @@
@@ -1,49 +0,0 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Sergej Andrejev |
||||
* Date: 7/23/2009 |
||||
* Time: 2:38 PM |
||||
*/ |
||||
using System; |
||||
|
||||
namespace ICSharpCode.Core.Presentation.CommandsService |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IBindingInfoTemplate.
|
||||
/// </summary>
|
||||
public interface IBindingInfoTemplate |
||||
{ |
||||
|
||||
public struct BindingInfoTemplate : IBindingInfo |
||||
{ |
||||
public string OwnerInstanceName |
||||
{ |
||||
get; set; |
||||
} |
||||
|
||||
public ICollection<UIElement> OwnerInstances |
||||
{ |
||||
get; set; |
||||
} |
||||
|
||||
public string OwnerTypeName |
||||
{ |
||||
get; set; |
||||
} |
||||
|
||||
public ICollection<Type> OwnerTypes |
||||
{ |
||||
get; set; |
||||
} |
||||
|
||||
public string RoutedCommandName |
||||
{ |
||||
get; set; |
||||
} |
||||
|
||||
public BindingGroupCollection Groups |
||||
{ |
||||
get; |
||||
} |
||||
} |
||||
} |
@ -1,19 +0,0 @@
@@ -1,19 +0,0 @@
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.Core.Presentation |
||||
{ |
||||
public struct InputBindingIdentifier |
||||
{ |
||||
public string OwnerInstanceName { |
||||
get; set; |
||||
} |
||||
|
||||
public string OwnerTypeName { |
||||
get; set; |
||||
} |
||||
|
||||
public string RoutedCommandName { |
||||
get; set; |
||||
} |
||||
} |
||||
} |
@ -1,30 +0,0 @@
@@ -1,30 +0,0 @@
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.Core.Presentation |
||||
{ |
||||
public class IBindingInfoTemplateEqualityComparer : IEqualityComparer<IBindingInfoTemplate> |
||||
{ |
||||
bool IEqualityComparer<IBindingInfoTemplate>.Equals(IBindingInfoTemplate key, IBindingInfoTemplate comparedValue) |
||||
{ |
||||
return key.OwnerInstanceName == comparedValue.OwnerInstanceName |
||||
&& key.OwnerTypeName == comparedValue.OwnerTypeName |
||||
&& key.RoutedCommandName == comparedValue.RoutedCommandName; |
||||
} |
||||
|
||||
int IEqualityComparer<IBindingInfoTemplate>.GetHashCode(IBindingInfoTemplate value) |
||||
{ |
||||
var instanceNameHashCode = value.OwnerInstanceName != null ? value.OwnerInstanceName.GetHashCode() : 0; |
||||
var typeNameHashCode = value.OwnerTypeName != null ? value.OwnerTypeName.GetHashCode() : 0; |
||||
var routedCommandNameHashCode = value.RoutedCommandName != null ? value.RoutedCommandName.GetHashCode() : 0; |
||||
var groupsHashCode = 0; |
||||
if(value.Groups != null) { |
||||
foreach(var group in value.Groups) { |
||||
groupsHashCode ^= group != null ? group.GetHashCode() : 0; |
||||
} |
||||
} |
||||
|
||||
return instanceNameHashCode ^ typeNameHashCode ^ routedCommandNameHashCode ^ groupsHashCode; |
||||
} |
||||
} |
||||
} |
@ -1,129 +0,0 @@
@@ -1,129 +0,0 @@
|
||||
using System; |
||||
using NUnit.Framework; |
||||
using ICSharpCode.Core.Presentation; |
||||
using SDCommandManager=ICSharpCode.Core.Presentation.CommandManager; |
||||
|
||||
namespace ICSharpCode.Core.Presentation.Tests |
||||
{ |
||||
[TestFixture] |
||||
public class BindingInfoTemplateTests |
||||
{ |
||||
[TestFixtureSetUp] |
||||
public void TestFixtureSetUp() |
||||
{ |
||||
PropertyService.InitializeServiceForUnitTests(); |
||||
} |
||||
|
||||
[SetUp] |
||||
public void SetuUp() |
||||
{ |
||||
} |
||||
|
||||
[TearDown] |
||||
public void TearDown() |
||||
{ |
||||
SDCommandManager.Reset(); |
||||
} |
||||
|
||||
[TestAttribute] |
||||
public void IsTemplateForSupersetsTests() |
||||
{ |
||||
var source = new InputBindingInfo(); |
||||
source.RoutedCommandName = "TestCommand"; |
||||
source.OwnerTypeName = "TestOwnerType"; |
||||
|
||||
var emptyTemplate = new BindingInfoTemplate(); |
||||
Assert.IsTrue(emptyTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet)); |
||||
|
||||
var matchingTemplate = new BindingInfoTemplate(); |
||||
matchingTemplate.RoutedCommandName = "TestCommand"; |
||||
Assert.IsTrue(matchingTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet)); |
||||
|
||||
var unmatchingTemplate = new BindingInfoTemplate(); |
||||
unmatchingTemplate.RoutedCommandName = "OtherTestCommand"; |
||||
Assert.IsFalse(unmatchingTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet)); |
||||
|
||||
var overlappingTemplate = new BindingInfoTemplate(); |
||||
overlappingTemplate.RoutedCommandName = "TestCommand"; |
||||
overlappingTemplate.OwnerInstanceName = "TestOwnerInstance"; |
||||
Assert.IsFalse(overlappingTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet)); |
||||
|
||||
var biggerTemplate = new BindingInfoTemplate(); |
||||
biggerTemplate.RoutedCommandName = "TestCommand"; |
||||
biggerTemplate.OwnerTypeName = "TestOwnerType"; |
||||
biggerTemplate.OwnerInstanceName = "TestOwnerInstance"; |
||||
Assert.IsFalse(biggerTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet)); |
||||
|
||||
var exactTemplate = new BindingInfoTemplate(); |
||||
exactTemplate.RoutedCommandName = "TestCommand"; |
||||
exactTemplate.OwnerTypeName = "TestOwnerType"; |
||||
Assert.IsTrue(exactTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet)); |
||||
} |
||||
|
||||
[TestAttribute] |
||||
public void IsTemplateForSubsetsTests() |
||||
{ |
||||
var source = new InputBindingInfo(); |
||||
source.RoutedCommandName = "TestCommand"; |
||||
source.OwnerTypeName = "TestOwnerType"; |
||||
|
||||
var emptyTemplate = new BindingInfoTemplate(); |
||||
Assert.IsFalse(emptyTemplate.IsTemplateFor(source, BindingInfoMatchType.SubSet)); |
||||
|
||||
var smallerTemplate = new BindingInfoTemplate(); |
||||
smallerTemplate.RoutedCommandName = "TestCommand"; |
||||
Assert.IsFalse(smallerTemplate.IsTemplateFor(source, BindingInfoMatchType.SubSet)); |
||||
|
||||
var overlappingTemplate = new BindingInfoTemplate(); |
||||
overlappingTemplate.RoutedCommandName = "TestCommand"; |
||||
overlappingTemplate.OwnerInstanceName = "TestOwnerInstance"; |
||||
Assert.IsFalse(overlappingTemplate.IsTemplateFor(source, BindingInfoMatchType.SubSet)); |
||||
|
||||
var biggerTemplate = new BindingInfoTemplate(); |
||||
biggerTemplate.RoutedCommandName = "TestCommand"; |
||||
biggerTemplate.OwnerTypeName = "TestOwnerType"; |
||||
biggerTemplate.OwnerInstanceName = "TestOwnerInstance"; |
||||
Assert.IsTrue(biggerTemplate.IsTemplateFor(source, BindingInfoMatchType.SubSet)); |
||||
|
||||
var exactTemplate = new BindingInfoTemplate(); |
||||
exactTemplate.RoutedCommandName = "TestCommand"; |
||||
exactTemplate.OwnerTypeName = "TestOwnerType"; |
||||
Assert.IsTrue(exactTemplate.IsTemplateFor(source, BindingInfoMatchType.SubSet)); |
||||
} |
||||
|
||||
[TestAttribute] |
||||
public void IsTemplateForPartlyMatchingTests() |
||||
{ |
||||
var source = new InputBindingInfo(); |
||||
source.RoutedCommandName = "TestCommand"; |
||||
source.OwnerTypeName = "TestOwnerType"; |
||||
|
||||
var emptyTemplate = new BindingInfoTemplate(); |
||||
Assert.IsTrue(emptyTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet | BindingInfoMatchType.SubSet)); |
||||
|
||||
var matchingTemplate = new BindingInfoTemplate(); |
||||
matchingTemplate.RoutedCommandName = "TestCommand"; |
||||
Assert.IsTrue(matchingTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet | BindingInfoMatchType.SubSet)); |
||||
|
||||
var unmatchingTemplate = new BindingInfoTemplate(); |
||||
unmatchingTemplate.RoutedCommandName = "OtherTestCommand"; |
||||
Assert.IsFalse(unmatchingTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet | BindingInfoMatchType.SubSet)); |
||||
|
||||
var overlappingTemplate = new BindingInfoTemplate(); |
||||
overlappingTemplate.RoutedCommandName = "TestCommand"; |
||||
overlappingTemplate.OwnerInstanceName = "TestOwnerInstance"; |
||||
Assert.IsFalse(overlappingTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet | BindingInfoMatchType.SubSet)); |
||||
|
||||
var biggerTemplate = new BindingInfoTemplate(); |
||||
biggerTemplate.RoutedCommandName = "TestCommand"; |
||||
biggerTemplate.OwnerTypeName = "TestOwnerType"; |
||||
biggerTemplate.OwnerInstanceName = "TestOwnerInstance"; |
||||
Assert.IsTrue(biggerTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet | BindingInfoMatchType.SubSet)); |
||||
|
||||
var exactTemplate = new BindingInfoTemplate(); |
||||
exactTemplate.RoutedCommandName = "TestCommand"; |
||||
exactTemplate.OwnerTypeName = "TestOwnerType"; |
||||
Assert.IsTrue(exactTemplate.IsTemplateFor(source, BindingInfoMatchType.SuperSet | BindingInfoMatchType.SubSet)); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue