コード例 #1
0
ファイル: Gh4099.xaml.cs プロジェクト: hevey/maui
 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();
     }
 }
コード例 #2
0
ファイル: Bz42531.xaml.cs プロジェクト: zhamppx97/maui
            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);
            }
コード例 #3
0
ファイル: GH2691.xaml.cs プロジェクト: microhobby/maui-linux
 public void TestXamlCompiler()
 {
     MockCompiler.Compile(typeof(Gh2691));
 }
コード例 #4
0
 public void DoesCompilesArgsInsideDataTemplate()
 {
     Assert.DoesNotThrow(() => MockCompiler.Compile(typeof(Bz53318)));
 }
コード例 #5
0
 public void MarkupOnAttachedBPDoesNotThrowAtCompileTime(bool useCompiledXaml)
 {
     MockCompiler.Compile(typeof(Bz53203));
 }
コード例 #6
0
 public void ThrowsOnMismatchingType([Values(true, false)] bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(7, 16, m => m.Contains("No property, BindableProperty")), () => MockCompiler.Compile(typeof(TypeMismatch)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 16, m => m.StartsWith("Cannot assign property", StringComparison.Ordinal)), () => new TypeMismatch(useCompiledXaml));
     }
 }
コード例 #7
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");
 }
コード例 #8
0
 public void OnPlatformExtensionsAreSimplified([Values("net6.0-ios", "net6.0-android")] string targetFramework)
 {
     MockCompiler.Compile(typeof(OnPlatformOptimization), out var methodDef, targetFramework);
     Assert.That(!methodDef.Body.Instructions.Any(instr => InstructionIsOnPlatformExtensionCtor(methodDef, instr)), "This Xaml still generates a new OnPlatformExtension()");
 }
コード例 #9
0
            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);
                Assert.AreEqual("Text3", vm.Text);
                ((IElementController)layout.entry1).SetValueFromRenderer(Entry.TextProperty, "Text4");
                Assert.AreEqual("Text4", layout.entry1.Text);
                Assert.AreEqual("Text4", vm.Model.Text);
                vm.Model = null;
                layout.entry1.BindingContext = null;

                //testing invalid bindingcontext type
                layout.BindingContext = new object();
                Assert.AreEqual(null, layout.label0.Text);
            }
コード例 #10
0
ファイル: Bz44216.xaml.cs プロジェクト: zhamppx97/maui
 public void DonSetValueOnPrivateBP(bool useCompiledXaml)
 {
     if (useCompiledXaml)
     {
         Assert.Throws(new BuildExceptionConstraint(7, 26, s => s.Contains("No property,")), () => MockCompiler.Compile(typeof(Bz44216)));
     }
     else
     {
         Assert.Throws(new XamlParseExceptionConstraint(7, 26, s => s.StartsWith("Cannot assign property", StringComparison.Ordinal)), () => new Bz44216(useCompiledXaml));
     }
 }
コード例 #11
0
 public void FontSizeExtensionsAreReplaced()
 {
     MockCompiler.Compile(typeof(FontSize), out var methodDef);
     Assert.That(!methodDef.Body.Instructions.Any(instr => InstructionIsFontSizeConverterCtor(methodDef, instr)), "This Xaml still generates a new FontSizeConverter()");
 }
コード例 #12
0
 public void ConvertersAreReplaced(Type converterType)
 {
     MockCompiler.Compile(typeof(CompiledTypeConverter), out var methodDef);
     Assert.That(!methodDef.Body.Instructions.Any(instr => HasConstructorForType(methodDef, instr, converterType)), $"This Xaml still generates a new {converterType}()");
 }
コード例 #13
0
 public static void ThrowXamlParseException(bool useCompiledXaml)
 {
     Assert.Throws <XamlParseException>(useCompiledXaml ?
                                        (TestDelegate)(() => MockCompiler.Compile(typeof(DuplicatePropertyElements))) :
                                        () => new DuplicatePropertyElements(useCompiledXaml));
 }
コード例 #14
0
 public static void ThrowXamlParseException(bool useCompiledXaml)
 {
     Assert.Throws <XamlParseException>(useCompiledXaml ?
                                        (TestDelegate)(() => MockCompiler.Compile(typeof(MultipleDataTemplateChildElements))) :
                                        () => new MultipleDataTemplateChildElements(useCompiledXaml));
 }