Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
Beispiel #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));
            }
Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
Beispiel #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));
     }
 }
Beispiel #12
0
 public void ThrowsOnDuplicateXKey(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh3512)));
     }
     else
     {
         Assert.Throws <ArgumentException>(() => new Gh3512(useCompiledXaml));
     }
 }
Beispiel #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));
     }
 }
Beispiel #14
0
 public void BindingContextWithConverter(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Bz55862)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Bz55862(useCompiledXaml));
     }
 }
Beispiel #15
0
 public void ReportMissingTargetTypeOnStyle(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh2064)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh2064(useCompiledXaml));
     }
 }
Beispiel #16
0
 public void ThrowsOnWrongEventHandlerSignature(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws <BuildException>(() => MockCompiler.Compile(typeof(Gh3082)));
     }
     else
     {
         Assert.Throws <XamlParseException>(() => new Gh3082(false));
     }
 }
Beispiel #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"));
            }
Beispiel #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"));
            }
Beispiel #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"));
            }
Beispiel #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);
            }
Beispiel #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");
 }