Exemple #1
0
        public void Bind_WithoutConverterMultipleTimes_Throws()
        {
            _bindingFactoryMock.Setup(mock => mock.CreatePropertyBinding(
                                          It.IsAny <BindingType>(),
                                          It.IsAny <IDependencyProperty <int> >(),
                                          It.IsAny <INotifyingObject <int> >(),
                                          It.IsAny <ValueConverter <int, int> >()))
            .Returns(Mock.Of <IBinding>());
            var subject = new DependencyProperty <int>(_bindingFactoryMock.Object);

            subject.Bind(BindingType.OneWay, Mock.Of <INotifyingObject <int> >());
            Assert.Throws <InvalidOperationException>(
                () => subject.Bind(BindingType.OneWay, Mock.Of <INotifyingObject <int> >()));
        }
Exemple #2
0
        public void Bind_WithoutConverterSourceNull_Throws()
        {
            var subject = new DependencyProperty <int>(_bindingFactoryMock.Object);

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => subject.Bind(BindingType.OneWay, null));
        }
Exemple #3
0
        public void Bind_OneWayToSourceValueConverterNull_Throws()
        {
            var subject = new DependencyProperty <int>(_bindingFactoryMock.Object);

            // ReSharper disable once AssignNullToNotNullAttribute
            Assert.Throws <ArgumentNullException>(() => subject.Bind(
                                                      Mock.Of <INotifyingObject <int> >(),
                                                      (OneWayToSourceValueConverter <int, int>)null));
        }
Exemple #4
0
        public void ClearBinding_Bind_BindingDisposed()
        {
            var bindingMock = new Mock <IBinding>();

            bindingMock.Setup(mock => mock.Close());
            _bindingFactoryMock.Setup(mock => mock.CreatePropertyBinding(
                                          It.IsAny <BindingType>(),
                                          It.IsAny <IDependencyProperty <int> >(),
                                          It.IsAny <INotifyingObject <int> >(),
                                          It.IsAny <ValueConverter <int, int> >()))
            .Returns(bindingMock.Object);
            var subject = new DependencyProperty <int>(_bindingFactoryMock.Object);

            subject.Bind(BindingType.TwoWay, Mock.Of <INotifyingObject <int> >());
            subject.ClearBinding();
            bindingMock.Verify(mock => mock.Close());
        }
Exemple #5
0
        public void Culture_Bound_BindingCultureSet()
        {
            var culture     = CultureInfo.InvariantCulture;
            var bindingMock = new Mock <IBinding>();

            bindingMock.SetupSet(mock => mock.Culture = culture);
            _bindingFactoryMock.Setup(mock => mock.CreatePropertyBinding(
                                          It.IsAny <BindingType>(),
                                          It.IsAny <IDependencyProperty <int> >(),
                                          It.IsAny <INotifyingObject <int> >(),
                                          It.IsAny <ValueConverter <int, int> >()))
            .Returns(bindingMock.Object);
            var subject = new DependencyProperty <int>(_bindingFactoryMock.Object);

            subject.Bind(BindingType.OneWay, Mock.Of <INotifyingObject <int> >());
            subject.Culture = culture;

            bindingMock.VerifySet(mock => mock.Culture = culture);
            Assert.AreEqual(culture, subject.Culture);
        }
Exemple #6
0
        public void Bind_WithoutConverter_CultureSet()
        {
            var culture     = CultureInfo.InvariantCulture;
            var bindingMock = new Mock <IBinding>();

            bindingMock.SetupSet(mock => mock.Culture = culture);
            _bindingFactoryMock.Setup(mock => mock.CreatePropertyBinding(
                                          It.IsAny <BindingType>(),
                                          It.IsAny <IDependencyProperty <int> >(),
                                          It.IsAny <INotifyingObject <int> >(),
                                          It.IsAny <ValueConverter <int, int> >()))
            .Returns(bindingMock.Object);
            var subject = new DependencyProperty <int>(_bindingFactoryMock.Object)
            {
                Culture = culture
            };

            subject.Bind(BindingType.TwoWay, Mock.Of <INotifyingObject <int> >());
            bindingMock.VerifySet(mock => mock.Culture = culture);
        }