Esempio n. 1
0
        public void CompareTemplateSelectorArgs()
        {
            StructAssert.IsCorrect <TemplateSelectorArgs <int> >();

            var arg = default(TemplateSelectorArgs <int>);

            DataTemplate template = new DataTemplate();

            Assert.AreEqual(
                template,
                TemplateSelector.Create <int>(
                    e =>
            {
                arg = e;

                return(template);
            }).SelectTemplate(1, null));

            StructAssert.AreEqual(arg, (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreNotEqual(arg, default(TemplateSelectorArgs <int>), (x, y) => x == y, (x, y) => x != y);

            new HashSet <TemplateSelectorArgs <int> > {
                default(TemplateSelectorArgs <int>), arg, arg
            };
        }
        public void CompareMultiValueConverterArgs()
        {
            StructAssert.IsCorrect <MultiValueConverterArgs <int> >();

            var arg1 = default(MultiValueConverterArgs <int>);
            var arg2 = default(MultiValueConverterArgs <int>);

            Assert.AreEqual(
                "3",
                MultiValueConverter.Create <int, string>(
                    e =>
            {
                arg1 = e;

                return(e.Values.Sum().ToString());
            })
                .Convert(new object[] { 1, 2 }, typeof(string), null, new CultureInfo("en-GB")));
            Assert.AreEqual(
                "6",
                MultiValueConverter.Create <int, string>(
                    e =>
            {
                arg2 = e;

                return(e.Values.Sum().ToString());
            })
                .Convert(new object[] { 1, 2, 3 }, typeof(string), null, new CultureInfo("en-GB")));

            StructAssert.AreEqual(default(MultiValueConverterArgs <int>), (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreEqual(arg1, (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreEqual(arg2, (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreNotEqual(arg1, arg2, (x, y) => x == y, (x, y) => x != y);

            new HashSet <MultiValueConverterArgs <int> > {
Esempio n. 3
0
        public void CompareValidationRuleArgs()
        {
            StructAssert.IsCorrect <ValidationRuleArgs <int> >();

            var arg = default(ValidationRuleArgs <int>);

            ValidationResult result = Validator.Create <int>(
                e =>
            {
                arg    = e;
                result = new ValidationResult(true, e.Value.ToString());
                return(result);
            }).Validate(1, new CultureInfo("en-GB"));

            Assert.AreEqual(
                result.ErrorContent,
                "1");

            StructAssert.AreEqual(arg, (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreNotEqual(arg, default(ValidationRuleArgs <int>), (x, y) => x == y, (x, y) => x != y);

            new HashSet <ValidationRuleArgs <int> > {
                default(ValidationRuleArgs <int>), arg, arg
            };
        }
Esempio n. 4
0
        public void CompareValueConverterArgs()
        {
            StructAssert.IsCorrect <ValueConverterArgs <int> >();

            var arg = default(ValueConverterArgs <int>);

            Assert.AreEqual(
                "1",
                ValueConverter.Create <int, string>(
                    e =>
            {
                arg = e;

                return(e.Value.ToString());
            }).Convert(1, typeof(string), null, new CultureInfo("en-GB")));

            StructAssert.AreEqual(arg, (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreNotEqual(arg, default, (x, y) => x == y, (x, y) => x != y);
        public void CompareValueConverterArgs_UsingConverterParameter()
        {
            StructAssert.IsCorrect <ValueConverterArgs <int, bool> >();

            var arg = default(ValueConverterArgs <int, bool>);

            Assert.AreEqual(
                "1",
                ValueConverter.Create <int, string, bool>(
                    e =>
            {
                arg = e;

                return(e.Value.ToString());
            }).Convert(1, typeof(string), true, new CultureInfo("en-GB")));

            StructAssert.AreEqual(arg, (x, y) => x == y, (x, y) => x != y);
            StructAssert.AreNotEqual(arg, default(ValueConverterArgs <int, bool>), (x, y) => x == y, (x, y) => x != y);

            new HashSet <ValueConverterArgs <int, bool> > {
                default(ValueConverterArgs <int, bool>), arg, arg
            };
        }