public void ErrorOnMissingDefaultCtor([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <XamlParseException>(() => MockCompiler.Compile(typeof(Gh4751)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh4751(useCompiledXaml));
     }
 }
Exemple #2
0
            public void GenericBPCompiles([Values(false, true)] bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    MockCompiler.Compile(typeof(Gh7559));
                }
                var layout = new Gh7559(useCompiledXaml);
                var value  = Gh7559Generic <Gh7559Enum> .GetIcon(layout);

                Assert.That(value, Is.EqualTo(Gh7559Enum.LetterA));
            }
 public void ThrowOnInstanceProperty(bool useCompiledXaml)
 {
     if (!useCompiledXaml)
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 6), () => new XStaticException(useCompiledXaml));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 6), () => MockCompiler.Compile(typeof(XStaticException)));
     }
 }
Exemple #4
0
 public void ThrowsOnDuplicateXKey(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <XamlParseException>(() => MockCompiler.Compile(typeof(Gh3512)));
     }
     else
     {
         Assert.Throws <ArgumentException>(() => new Gh3512(useCompiledXaml));
     }
 }
Exemple #5
0
 public void UnescapedBraces([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <XamlParseException>(() => MockCompiler.Compile(typeof(Gh2756)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh2756(useCompiledXaml));
     }
 }
Exemple #6
0
 public void ThrowsOnWrongEventHandlerSignature(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh3082)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh3082(false));
     }
 }
Exemple #7
0
 //this requirement might change, see https://github.com/xamarin/Xamarin.Forms/issues/12425
 public void xKeyRequireStringLiteral([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(xKeyLiteral)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new xKeyLiteral(useCompiledXaml));
     }
 }
Exemple #8
0
 public void FormatExceptionAreCaught([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh11711)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh11711(useCompiledXaml));
     }
 }
Exemple #9
0
 public void Throw(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new XamlParseExceptionConstraint(8, 4), () => MockCompiler.Compile(typeof(FactoryMethodMissingMethod)));
     }
     else
     {
         Assert.Throws <MissingMemberException>(() => new FactoryMethodMissingMethod());
     }
 }
Exemple #10
0
 public void ThrowsOnInvalidXaml([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh5095)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh5095(false));
     }
 }
Exemple #11
0
 public void InvalidMarkupAssignmentThrowsXPE([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh7187)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh7187(useCompiledXaml));
     }
 }
Exemple #12
0
 public void DoesNotAllowGridRowDefinition(bool useCompiledXaml)
 {
     if (!useCompiledXaml)
     {
         Assert.Throws <XamlParseException>(() => new Bz43450(useCompiledXaml));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => MockCompiler.Compile(typeof(Bz43450)));
     }
 }
Exemple #13
0
 public void ShouldThrow(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(10, 13), () => MockCompiler.Compile(typeof(SetterOnNonBP)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(10, 13), () => new SetterOnNonBP(useCompiledXaml));
     }
 }
Exemple #14
0
            public void FindStaticInternal(bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Gh4326)));
                }
                var layout = new Gh4326(useCompiledXaml);

                Assert.That(layout.labelfoo.Text, Is.EqualTo("Foo"));
                Assert.That(layout.labelbar.Text, Is.EqualTo("Bar"));
                Assert.That(layout.labelinternalvisibleto.Text, Is.EqualTo(Style.StyleClassPrefix));
            }
Exemple #15
0
            public void GenericBaseInterfaceResolution(bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Gh5651)));
                }
                var layout = new Gh5651(useCompiledXaml)
                {
                    BindingContext = new Gh5651VM()
                };

                Assert.That(layout.label.Text, Is.EqualTo("test"));
            }
Exemple #16
0
            public void BindingWithMultipleIndexers([Values(false, true)] bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    MockCompiler.Compile(typeof(Gh7837));
                }
                var layout = new Gh7837(useCompiledXaml);

                Assert.That(layout.label0.Text, Is.EqualTo("forty-two"));
                Assert.That(layout.label1.Text, Is.EqualTo("FOO"));
                Assert.That(layout.label2.Text, Is.EqualTo("forty-two"));
                Assert.That(layout.label3.Text, Is.EqualTo("FOO"));
            }
Exemple #17
0
 public void ThrowMeaningfulExceptionOnDuplicateXName(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new XamlParseExceptionConstraint(8, 10, m => m == "An element with the name \"label0\" already exists in this NameScope"),
                       () => MockCompiler.Compile(typeof(Issue2450)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(8, 10, m => m == "An element with the name \"label0\" already exists in this NameScope"),
                       () => new Issue2450(useCompiledXaml));
     }
 }
Exemple #18
0
            public void BindingAsElement(bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Gh4572)));
                }
                var layout = new Gh4572(useCompiledXaml)
                {
                    BindingContext = new { labeltext = "Foo" }
                };

                Assert.That(layout.label.Text, Is.EqualTo("Foo"));
            }
Exemple #19
0
 public void BetterExceptionReport(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         try {
             MockCompiler.Compile(typeof(Gh4099));
         } catch (BuildException xpe) {
             Assert.That(xpe.XmlInfo.LineNumber, Is.EqualTo(5));
             Assert.Pass();
         }
         Assert.Fail();
     }
 }
Exemple #20
0
 public void XamlCBindingOnNonBP([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh11061)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh11061(useCompiledXaml)
         {
             BindingContext = new { Date = DateTime.Today }
         });
     }
 }
Exemple #21
0
            public void FindMemberOnInterfaces(bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Gh4227)));
                }
                var layout = new Gh4227(useCompiledXaml)
                {
                    BindingContext = new Gh4227VM()
                };

                Assert.That(layout.label0.Text, Is.EqualTo("level0"));
                Assert.That(layout.label1.Text, Is.EqualTo("level1"));
            }
Exemple #22
0
            public void BindingWithMultipleIndexers([Values(false, true)] bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    MockCompiler.Compile(typeof(Gh8221));
                }
                var layout = new Gh8221(useCompiledXaml)
                {
                    BindingContext = new Gh8221VM()
                };

                Assert.That(layout.entryone.Text, Is.EqualTo("One"));
                Assert.That(layout.entrytwo.Text, Is.EqualTo("Two"));
            }
Exemple #23
0
            public void RDInDataTemplates(bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    MockCompiler.Compile(typeof(Bz42531));
                }
                var      p        = new Bz42531(useCompiledXaml);
                ListView lv       = p.lv;
                var      template = lv.ItemTemplate;
                var      cell     = template.CreateContent(null, lv) as ViewCell;
                var      sl       = cell.View as StackLayout;

                Assert.AreEqual(1, sl.Resources.Count);
                var label = sl.Children[0] as Label;

                Assert.AreEqual(LayoutOptions.Center, label.HorizontalOptions);
            }
Exemple #24
0
 public void TestXamlCompiler()
 {
     MockCompiler.Compile(typeof(Gh2691));
 }
 public static void ThrowXamlParseException(bool useCompiledXaml)
 {
     Assert.Throws <XamlParseException>(useCompiledXaml ?
                                        (TestDelegate)(() => MockCompiler.Compile(typeof(MultipleDataTemplateChildElements))) :
                                        () => new MultipleDataTemplateChildElements(useCompiledXaml));
 }
Exemple #26
0
 public void DonSetValueOnPrivateBP(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 26, s => s.StartsWith("No property,", StringComparison.Ordinal)), () => MockCompiler.Compile(typeof(Bz44216)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 26, s => s.StartsWith("Cannot assign property", StringComparison.Ordinal)), () => new Bz44216(useCompiledXaml));
     }
 }
 public void ThrowsOnMismatchingType([Values(true, false)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 16, m => m.StartsWith("No property, bindable property", StringComparison.Ordinal)), () => MockCompiler.Compile(typeof(TypeMismatch)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 16, m => m.StartsWith("Cannot assign property", StringComparison.Ordinal)), () => new TypeMismatch(useCompiledXaml));
     }
 }
Exemple #28
0
 public void DoesCompilesArgsInsideDataTemplate()
 {
     Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Bz53318)));
 }
 public static void ThrowXamlParseException(bool useCompiledXaml)
 {
     Assert.Throws <XamlParseException>(useCompiledXaml ?
                                        (TestDelegate)(() => MockCompiler.Compile(typeof(DuplicateXArgumentsElements))) :
                                        () => new DuplicateXArgumentsElements(useCompiledXaml));
 }
            public void Test(bool useCompiledXaml)
            {
                if (useCompiledXaml)
                {
                    MockCompiler.Compile(typeof(BindingsCompiler));
                }
                var vm = new MockViewModel {
                    Text  = "Text0",
                    I     = 42,
                    Model = new MockViewModel {
                        Text = "Text1"
                    },
                    StructModel = new MockStructViewModel {
                        Model = new MockViewModel {
                            Text = "Text9"
                        }
                    }
                };

                vm.Model [3] = "TextIndex";

                var layout = new BindingsCompiler(useCompiledXaml);

                layout.BindingContext        = vm;
                layout.label6.BindingContext = new MockStructViewModel {
                    Model = new MockViewModel {
                        Text = "text6"
                    }
                };

                //testing paths
                Assert.AreEqual("Text0", layout.label0.Text);
                Assert.AreEqual("Text0", layout.label1.Text);
                Assert.AreEqual("Text1", layout.label2.Text);
                Assert.AreEqual("TextIndex", layout.label3.Text);
                Assert.AreEqual("Text0", layout.label8.Text);

                //value types
                Assert.That(layout.label5.Text, Is.EqualTo("42"));
                Assert.That(layout.label6.Text, Is.EqualTo("text6"));
                Assert.AreEqual("Text9", layout.label9.Text);
                Assert.AreEqual("Text9", layout.label10.Text);
                layout.label9.Text = "Text from label9";
                Assert.AreEqual("Text from label9", vm.StructModel.Text);
                layout.label10.Text = "Text from label10";
                Assert.AreEqual("Text from label10", vm.StructModel.Model.Text);

                //testing selfPath
                layout.label4.BindingContext = "Self";
                Assert.AreEqual("Self", layout.label4.Text);
                layout.label7.BindingContext = 42;
                Assert.That(layout.label7.Text, Is.EqualTo("42"));

                //testing INPC
                GC.Collect();
                vm.Text = "Text2";
                Assert.AreEqual("Text2", layout.label0.Text);

                //testing 2way
                Assert.AreEqual("Text2", layout.entry0.Text);
                ((IElementController)layout.entry0).SetValueFromRenderer(Entry.TextProperty, "Text3");
                Assert.AreEqual("Text3", layout.entry0.Text);

                //testing invalid bindingcontext type
                layout.BindingContext = new object();
                Assert.AreEqual(null, layout.label0.Text);
            }