Example #1
0
 //this requirement might change, see https://github.com/xamarin/Microsoft.Maui.Controls/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));
     }
 }
Example #2
0
 public void ThrowOnInstanceProperty(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(7, 6), () => MockCompiler.Compile(typeof(XStaticException)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 6), () => new XStaticException(useCompiledXaml));
     }
 }
Example #3
0
 public void ReportSyntaxError([Values(false /*, true*/)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh5378_1)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh5378_1(useCompiledXaml));
     }
 }
Example #4
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));
     }
 }
Example #5
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));
            }
Example #6
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));
     }
 }
Example #7
0
 public void Throw([Values(false, true)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(7, 4), () => MockCompiler.Compile(typeof(FactoryMethodMissingCtor)));
     }
     else
     {
         Assert.Throws <MissingMethodException>(() => new FactoryMethodMissingCtor(useCompiledXaml));
     }
 }
 public void InvalidSourceThrows(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(8, 33), () => MockCompiler.Compile(typeof(ResourceDictionaryWithInvalidSource)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(8, 33), () => new ResourceDictionaryWithInvalidSource(useCompiledXaml));
     }
 }
Example #9
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));
     }
 }
Example #10
0
 public void DetailedErrorMessageOnMissingXmlnsDeclaration(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh2063)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh2063(useCompiledXaml));
     }
 }
 public void Throw(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(8, 4), () => MockCompiler.Compile(typeof(FactoryMethodMissingMethod)));
     }
     else
     {
         Assert.Throws <MissingMemberException>(() => new FactoryMethodMissingMethod(useCompiledXaml));
     }
 }
Example #12
0
 public void ThrowsOnDuplicateXKey(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh3512)));
     }
     else
     {
         Assert.Throws <ArgumentException>(() => new Gh3512(useCompiledXaml));
     }
 }
Example #13
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));
     }
 }
Example #14
0
 public void BindingContextWithConverter(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Bz55862)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Bz55862(useCompiledXaml));
     }
 }
Example #15
0
 public void ReportMissingTargetTypeOnStyle(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh2064)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh2064(useCompiledXaml));
     }
 }
Example #16
0
 public void ThrowsOnWrongEventHandlerSignature(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh3082)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh3082(false));
     }
 }
Example #17
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"));
            }
Example #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"));
            }
Example #19
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"));
            }
Example #20
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);
            }
Example #21
0
 public void DefinitionCollectionsReplacedAtCompilation()
 {
     MockCompiler.Compile(typeof(DefinitionCollectionTests), out var methodDef);
     Assert.That(!methodDef.Body.Instructions.Any(instr => InstructionIsDefColConvCtor(methodDef, instr)), "This Xaml still generates [Row|Col]DefinitionCollectionTypeConverter ctor");
 }