Permalink
Browse files

Write a test for inherited events and exercising the top-level binder…

… code
  • Loading branch information...
1 parent 840f0e9 commit f154420dfcc5039a95802747134fab189f2386b1 @paulcbetts paulcbetts committed Oct 26, 2012
Showing with 37 additions and 2 deletions.
  1. +36 −0 ReactiveUI.Tests/CommandBindingTests.cs
  2. +1 −2 ReactiveUI.Xaml/ServiceLocationRegistration.cs
@@ -13,6 +13,34 @@
namespace ReactiveUI.Tests
{
+ public class FakeViewModel : ReactiveObject
+ {
+ public ReactiveCommand Cmd { get; protected set; }
+
+ public FakeViewModel()
+ {
+ Cmd = new ReactiveCommand();
+ }
+ }
+
+ public class FakeView : IViewFor<FakeViewModel>
+ {
+ public TextBox TheTextBox { get; protected set; }
+
+ public FakeView()
+ {
+ TheTextBox = new TextBox();
+ ViewModel = new FakeViewModel();
+ }
+
+ object IViewFor.ViewModel {
+ get { return ViewModel; }
+ set { ViewModel = (FakeViewModel)value; }
+ }
+
+ public FakeViewModel ViewModel { get; set; }
+ }
+
public class CreatesCommandBindingTests
{
[Fact]
@@ -60,6 +88,14 @@ public void EventBinderBindsToExplicitEvent()
Assert.False(wasCalled);
}
+ [Fact]
+ public void EventBinderBindsToExplicitInheritedEvent()
+ {
+ var fixture = new FakeView();
+ fixture.BindCommand(fixture.ViewModel, x => x.Cmd, x => x.TheTextBox, "MouseDown");
+ }
+
+
#if !SILVERLIGHT
[Fact]
public void EventBinderBindsToImplicitEvent()
@@ -25,8 +25,7 @@ public void Register()
#if !WINRT
RxApp.Register(typeof (DependencyObjectObservableForProperty), typeof (ICreatesObservableForProperty));
#endif
-
- RxApp.Register(typeof (XamlDefaultPropertyBinding), typeof (IDefaultPropertyBindingProvider));
+ RxApp.Register(typeof (XamlDefaultPropertyBinding), typeof (IDefaultPropertyBindingProvider));
RxApp.Register(typeof (CommandBinderImplementation), typeof (ICommandBinderImplementation));
RxApp.Register(typeof (CreatesCommandBindingViaCommandParameter), typeof(ICreatesCommandBinding));
RxApp.Register(typeof (CreatesCommandBindingViaEvent), typeof(ICreatesCommandBinding));

0 comments on commit f154420

Please sign in to comment.