public void convert_passes_parameters_into_converters()
        {
            var converter = new ConverterGroup();
            var value = "abc";
            var targetType = typeof(int);
            var parameter = "parameter";
            var cultureInfo = new CultureInfo("de-DE");
            var converterMock = new Mock<IValueConverter>();
            converterMock.Setup(x => x.Convert(value, targetType, parameter, cultureInfo)).Verifiable();
            converter.Converters.Add(converterMock.Object);

            converter.Convert(value, targetType, parameter, cultureInfo);

            converterMock.Verify();
        }
示例#2
0
        public void convert_passes_parameters_into_converters()
        {
            var converter     = new ConverterGroup();
            var value         = "abc";
            var targetType    = typeof(int);
            var parameter     = "parameter";
            var cultureInfo   = new CultureInfo("de-DE");
            var converterMock = new Mock <IValueConverter>();

            converterMock.Setup(x => x.Convert(value, targetType, parameter, cultureInfo)).Verifiable();
            converter.Converters.Add(converterMock.Object);

            converter.Convert(value, targetType, parameter, cultureInfo);

            converterMock.Verify();
        }
        public void convert_chains_converters_together_in_order()
        {
            var converter = new ConverterGroup();
            var converterMock1 = new Mock<IValueConverter>();
            var converterMock2 = new Mock<IValueConverter>();
            var converterMock3 = new Mock<IValueConverter>();
            converterMock1.Setup(x => x.Convert("start value", null, null, null)).Returns("converter1 result").Verifiable();
            converterMock2.Setup(x => x.Convert("converter1 result", null, null, null)).Returns("converter2 result").Verifiable();
            converterMock3.Setup(x => x.Convert("converter2 result", null, null, null)).Returns("converter3 result").Verifiable();
            converter.Converters.Add(converterMock1.Object);
            converter.Converters.Add(converterMock2.Object);
            converter.Converters.Add(converterMock3.Object);

            Assert.Equal("converter3 result", converter.Convert("start value", null, null, null));

            converterMock1.Verify();
            converterMock2.Verify();
            converterMock3.Verify();
        }
示例#4
0
        public void convert_chains_converters_together_in_order()
        {
            var converter      = new ConverterGroup();
            var converterMock1 = new Mock <IValueConverter>();
            var converterMock2 = new Mock <IValueConverter>();
            var converterMock3 = new Mock <IValueConverter>();

            converterMock1.Setup(x => x.Convert("start value", null, null, null)).Returns("converter1 result").Verifiable();
            converterMock2.Setup(x => x.Convert("converter1 result", null, null, null)).Returns("converter2 result").Verifiable();
            converterMock3.Setup(x => x.Convert("converter2 result", null, null, null)).Returns("converter3 result").Verifiable();
            converter.Converters.Add(converterMock1.Object);
            converter.Converters.Add(converterMock2.Object);
            converter.Converters.Add(converterMock3.Object);

            Assert.Equal("converter3 result", converter.Convert("start value", null, null, null));

            converterMock1.Verify();
            converterMock2.Verify();
            converterMock3.Verify();
        }
示例#5
0
        public void convert_returns_unset_value_if_there_are_no_converters()
        {
            var converter = new ConverterGroup();

            Assert.Equal(DependencyProperty.UnsetValue, converter.Convert("abc", null, null, null));
        }
 public void convert_returns_unset_value_if_there_are_no_converters()
 {
     var converter = new ConverterGroup();
     Assert.Equal(DependencyProperty.UnsetValue, converter.Convert("abc", null, null, null));
 }