Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: 4.0.3
Fetching contributors…

Cannot retrieve contributors at this time

65 lines (53 sloc) 1.813 kb
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reactive;
using System.Text;
using System.Windows.Controls;
using ReactiveUI.Xaml;
using Xunit;
namespace ReactiveUI.Tests
{
public class PropertyBindViewModel : ReactiveObject
{
public string _Property1;
public string Property1 {
get { return _Property1; }
set { this.RaiseAndSetIfChanged(x => x.Property1, value); }
}
}
public class PropertyBindView : IViewFor<PropertyBindViewModel>
{
object IViewFor.ViewModel {
get { return ViewModel; }
set { ViewModel = (PropertyBindViewModel)value; }
}
public PropertyBindViewModel ViewModel { get; set; }
public TextBox SomeTextBox { get; protected set; }
public PropertyBindView()
{
SomeTextBox = new TextBox();
}
}
public class PropertyBindingTest
{
[Fact]
public void TwoWayBindSmokeTest()
{
var vm = new PropertyBindViewModel();
var view = new PropertyBindView() {ViewModel = vm};
var fixture = new PropertyBinderImplementation();
vm.Property1 = "Foo";
Assert.NotEqual(vm.Property1, view.SomeTextBox.Text);
var disp = fixture.Bind(vm, view, x => x.Property1, x => x.SomeTextBox.Text, (IObservable<Unit>)null);
Assert.Equal(vm.Property1, view.SomeTextBox.Text);
Assert.Equal("Foo", vm.Property1);
view.SomeTextBox.Text = "Bar";
Assert.Equal(vm.Property1, "Bar");
disp.Dispose();
vm.Property1 = "Baz";
Assert.Equal("Baz", vm.Property1);
Assert.NotEqual(vm.Property1, view.SomeTextBox.Text);
}
}
}
Jump to Line
Something went wrong with that request. Please try again.