ISubsequentSourceBindingOptions IMultiSourceBindingOptions.To(object sourceObject, string sourcePath)
 {
     _currentChildBinding = new Binding {
         SourceObject = sourceObject, SourcePath = sourcePath
     };
     return(this);
 }
		public void the_converted_value_is_used_when_the_target_is_changed(BindingManager bindingManager, SingleSourceBinding binding, Mock<IValueConverter> converter, IPerson targetObject, IPerson sourceObject)
		{
			converter.Setup(x => x.ConvertBack("Value", typeof(string), "parameter", null)).Returns("Converted Value");
			targetObject.Address.Line2 = "Value";
			Assert.Equal("Converted Value", sourceObject.Address.Line1);
			converter.VerifyAll();
		}
 ISubsequentSourceBindingOptions IMultiSourceBindingOptions.To <TSource>(
     TSource sourceObject, Expression <Func <TSource, object> > sourceExpression)
 {
     _currentChildBinding = new TypedBinding <object, TSource> {
         SourceObject = sourceObject, SourceExpression = sourceExpression
     };
     return(this);
 }
		public void it_is_not_yet_active(SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			sourceObject.Name = "New Name";
			Assert.Null(targetObject.Name);

			targetObject.Name = "Another Name";
			Assert.Equal("New Name", sourceObject.Name);
		}
		public void conversions_from_target_to_source_are_ignored_when_there_is_no_converter(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			targetObject.Name = "Kent";
			Assert.Null(sourceObject.Gender);

			targetObject.Name = "Male";
			Assert.Null(sourceObject.Gender);
		}
		public void conversions_from_target_to_source_are_automatically_converted_where_possible(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			targetObject.Name = "69";
			Assert.Equal(69, sourceObject.Age);

			targetObject.Name = "13a";
			Assert.Equal(69, sourceObject.Age);
		}
		public void it_becomes_active(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			sourceObject.Name = "New Name";
			Assert.Equal("New Name", targetObject.Name);

			targetObject.Name = "Another Name";
			Assert.Equal("Another Name", sourceObject.Name);
		}
		public void it_has_no_target_path(SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject)
		{
			var binding = singleSourceBinding as Binding;

			if (binding == null)
			{
				return;
			}

			Assert.Null(binding.TargetPath);
		}
		public void it_has_the_correct_target_path(SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject)
		{
			var binding = singleSourceBinding as Binding;

			if (binding == null)
			{
				return;
			}

			Assert.Same("Name", binding.TargetPath);
		}
		public void it_has_no_source_expression(SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject)
		{
			var typedBinding = singleSourceBinding as TypedBinding<IPerson, IPerson>;

			if (typedBinding == null)
			{
				return;
			}

			Assert.Null(typedBinding.SourceExpression);
		}
		public void it_has_no_target_object(SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			Assert.Null(binding.TargetObject);
		}
		public void conversions_from_source_to_target_are_ignored_when_there_is_no_converter(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			sourceObject.Gender = Gender.Male;
			Assert.Null(targetObject.Name);
		}
		public void it_is_present_in_the_bindings_collection(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			Assert.Contains(binding, bindingManager.Bindings);
		}
		public void the_converter_parameter_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			var ex = Assert.Throws<InvalidOperationException>(() => binding.ConverterParameter = "whatever");
			Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message);
		}
		public void the_mode_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			var ex = Assert.Throws<InvalidOperationException>(() => binding.Mode = BindingMode.OneWayToTarget);
			Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message);
		}
		public void it_cannot_be_added_again(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			var ex = Assert.Throws<InvalidOperationException>(() => bindingManager.Bindings.Add(binding));
			Assert.Equal("This binding is already activated.", ex.Message);
		}
		public void the_target_expression_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject)
		{
			var typedBinding = singleSourceBinding as TypedBinding<IPerson, IPerson>;

			if (typedBinding == null)
			{
				return;
			}

			var ex = Assert.Throws<InvalidOperationException>(() => typedBinding.TargetExpression = null);
			Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message);
		}
		public void the_convert_target_to_source_method_is_called_when_the_target_is_changed(BindingManager bindingManager, SingleSourceBinding binding, Mock<IValueConverter> converter, IPerson targetObject, IPerson sourceObject)
		{
			converter.Setup(x => x.ConvertBack("Value", typeof(string), "parameter", null));
			targetObject.Address.Line2 = "Value";
			converter.VerifyAll();
		}
		public void conversions_from_source_to_target_are_automatically_converted_where_possible(BindingManager bindingManager, SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			sourceObject.Age = 69;
			Assert.Equal("69", targetObject.Name);
		}
		public void it_has_the_correct_target(SingleSourceBinding binding, IPerson targetObject, IPerson sourceObject)
		{
			Assert.Same(targetObject, binding.TargetObject);
		}
		public void the_source_path_cannot_be_modified(BindingManager bindingManager, SingleSourceBinding singleSourceBinding, IPerson targetObject, IPerson sourceObject)
		{
			var binding = singleSourceBinding as Binding;

			if (binding == null)
			{
				return;
			}

			var ex = Assert.Throws<InvalidOperationException>(() => binding.SourcePath = null);
			Assert.Equal("BindingBase is currently activated and cannot be modified.", ex.Message);
		}