Browse Source
This is needed in order to be able to use bindings as selectors, e.g. for TreeDataTemplate.ItemsSelector.pull/237/head
11 changed files with 72 additions and 140 deletions
@ -1,27 +0,0 @@ |
|||
// Copyright (c) The Perspex Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using System; |
|||
using Moq; |
|||
using Perspex.Markup.Xaml.Binding; |
|||
using OmniXaml.TypeConversion; |
|||
using Xunit; |
|||
|
|||
namespace Perspex.Xaml.Base.UnitTest |
|||
{ |
|||
public class BinderTest |
|||
{ |
|||
[Fact] |
|||
public void NullTarget_Throws() |
|||
{ |
|||
var typeConverter = new Mock<ITypeConverterProvider>(); |
|||
var perspexPropertyBinder = new PerspexPropertyBinder(typeConverter.Object); |
|||
var bindingDefinitionBuilder = new BindingDefinitionBuilder(); |
|||
var binding = bindingDefinitionBuilder |
|||
.WithNullTarget() |
|||
.Build(); |
|||
|
|||
var exception = Assert.Throws<InvalidOperationException>(() => perspexPropertyBinder.Create(binding)); |
|||
} |
|||
} |
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
// Copyright (c) The Perspex Project. All rights reserved.
|
|||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|||
|
|||
using Perspex.Controls; |
|||
using Perspex.Markup.Xaml.Binding; |
|||
|
|||
namespace Perspex.Xaml.Base.UnitTest |
|||
{ |
|||
public class BindingDefinitionBuilder |
|||
{ |
|||
private readonly BindingMode _bindingMode; |
|||
private readonly string _sourcePropertyPath; |
|||
private Control _target; |
|||
|
|||
public BindingDefinitionBuilder() |
|||
{ |
|||
_bindingMode = BindingMode.Default; |
|||
_sourcePropertyPath = string.Empty; |
|||
} |
|||
|
|||
public BindingDefinitionBuilder WithNullTarget() |
|||
{ |
|||
_target = null; |
|||
return this; |
|||
} |
|||
|
|||
public XamlBindingDefinition Build() |
|||
{ |
|||
return new XamlBindingDefinition( |
|||
bindingMode: _bindingMode, |
|||
sourcePropertyPath: _sourcePropertyPath, |
|||
target: _target, |
|||
targetProperty: null); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue