public void TestConvertBack() { IBindingValueConverter converter = new InverseBooleanValueConverter(); converter.ConvertBack(false, typeof(bool), null, null, null).ShouldEqual(true); converter.ConvertBack(true, typeof(bool), null, null, null).ShouldEqual(false); }
public void TestConvertBackNotBool() { IBindingValueConverter converter = new InverseBooleanValueConverter(); Action action = () => converter.ConvertBack(new object(), typeof(object), null, null, null); action.ShouldThrow(); }
public void ResolverShouldThrowExceptionIfConverterIsAlreadyRegisteredRewriteFalse() { const string name = "name"; var source = new InverseBooleanValueConverter(); var resolver = CreateBindingResourceResolver(); resolver.AddConverter(name, source, false); ShouldThrow(() => resolver.AddConverter(name, source, false)); }
public void ResolverShouldThrowExceptionIfConverterIsAlreadyRegisteredRewriteFalse() { const string name = "name"; var source = new InverseBooleanValueConverter(); var resolver = CreateBindingResourceResolver(); resolver.AddConverter(name, source, false); ShouldThrow(() => resolver.AddConverter(name, source, false)); }
public void ResolverShouldRegisterAndResolveConverter() { const string name = "name"; var source = new InverseBooleanValueConverter(); var resolver = CreateBindingResourceResolver(); resolver.ResolveConverter(name, EmptyContext, false).ShouldBeNull(); resolver.AddConverter(name, source, true); resolver.ResolveConverter(name, EmptyContext, true).ShouldEqual(source); }
public void ResolverShouldNotThrowExceptionIfConverterIsAlreadyRegisteredRewriteTrue() { const string name = "name"; var source = new InverseBooleanValueConverter(); var source2 = new InverseBooleanValueConverter(); var resolver = CreateBindingResourceResolver(); resolver.AddConverter(name, source, true); resolver.AddConverter(name, source2, true); resolver.ResolveConverter(name, EmptyContext, true).ShouldEqual(source2); }
public void ResolverShouldRegisterAndResolveConverter() { const string name = "name"; var source = new InverseBooleanValueConverter(); var resolver = CreateBindingResourceResolver(); resolver.ResolveConverter(name, EmptyContext, false).ShouldBeNull(); resolver.AddConverter(name, source, true); resolver.ResolveConverter(name, EmptyContext, true).ShouldEqual(source); }
public void ResolverShouldNotThrowExceptionIfConverterIsAlreadyRegisteredRewriteTrue() { const string name = "name"; var source = new InverseBooleanValueConverter(); var source2 = new InverseBooleanValueConverter(); var resolver = CreateBindingResourceResolver(); resolver.AddConverter(name, source, true); resolver.AddConverter(name, source2, true); resolver.ResolveConverter(name, EmptyContext, true).ShouldEqual(source2); }
public void ParserShouldParseConverterFromResource() { const string binding = "Text Text, Converter=$param"; var value = new InverseBooleanValueConverter(); var resolver = new BindingResourceResolver(); resolver.AddObject("param", new BindingResourceObject(value), true); IBindingParser bindingParser = CreateBindingParser(bindingProvider: new BindingProvider()); BindingServiceProvider.ResourceResolver = resolver; var context = new BindingBuilder(bindingParser.Parse(binding, EmptyContext, new object(), null).Single()); context.GetData(BindingBuilderConstants.Converter) .Invoke(EmptyContext) .ShouldEqual(value); }
public void TestConvertBack() { IBindingValueConverter converter = new InverseBooleanValueConverter(); converter.ConvertBack(false, typeof(bool), null, null, null).ShouldEqual(true); converter.ConvertBack(true, typeof(bool), null, null, null).ShouldEqual(false); }
public void TestConvertBackNotBool() { IBindingValueConverter converter = new InverseBooleanValueConverter(); Action action = () => converter.ConvertBack(new object(), typeof(object), null, null, null); action.ShouldThrow(); }
public void ParserShouldParseConverterName() { const string converterName = "test"; const string binding = "Text SourceText, Converter=test"; var value = new InverseBooleanValueConverter(); var resolver = new BindingResourceResolver(); resolver.AddConverter(converterName, value, true); IBindingParser bindingParser = CreateBindingParser(bindingProvider: new BindingProvider()); BindingServiceProvider.ResourceResolver = resolver; var context = new BindingBuilder(bindingParser.Parse(new object(), binding, null, null).Single()); context.GetData(BindingBuilderConstants.Converter).Invoke(EmptyContext).ShouldEqual(value); }