Inheritance: ClassAInner1
Example #1
0
        public void TestWoopsaObjectAdapterVisibility()
        {
            ClassAInner1 aInner1 = new ClassAInner1();
            // DefaultIsvisible false
            WoopsaObjectAdapter adapterA1 = new WoopsaObjectAdapter(null, "a", aInner1,
                                                                    null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.None);

            Assert.IsNull(adapterA1.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
            Assert.IsNull(adapterA1.Properties.ByNameOrNull(nameof(aInner1.APropertyIntHidden)));
            Assert.IsNotNull(adapterA1.Properties.ByNameOrNull(nameof(aInner1.APropertyIntVisible)));
            Assert.IsNull(adapterA1.Methods.ByNameOrNull(nameof(aInner1.ToString)));
            // DefaultIsvisible true
            WoopsaObjectAdapter adapterA2 = new WoopsaObjectAdapter(null, "a", aInner1,
                                                                    null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.DefaultIsVisible);

            Assert.IsNotNull(adapterA2.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
            Assert.IsNull(adapterA2.Methods.ByNameOrNull(nameof(aInner1.ToString)));
            // DefaultVisibility
            WoopsaObjectAdapter adapterA3 = new WoopsaObjectAdapter(null, "a", aInner1);

            Assert.IsNotNull(adapterA3.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
            Assert.IsNull(adapterA3.Properties.ByNameOrNull(nameof(aInner1.APropertyIntHidden)));
            Assert.IsNotNull(adapterA3.Properties.ByNameOrNull(nameof(aInner1.APropertyIntVisible)));
            Assert.IsNull(adapterA3.Methods.ByNameOrNull(nameof(aInner1.ToString)));
            // Visiblity All
            WoopsaObjectAdapter adapterA4 = new WoopsaObjectAdapter(null, "a", aInner1,
                                                                    null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.All);

            Assert.IsNotNull(adapterA4.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
            Assert.IsNull(adapterA4.Properties.ByNameOrNull(nameof(aInner1.APropertyIntHidden)));
            Assert.IsNotNull(adapterA4.Properties.ByNameOrNull(nameof(aInner1.APropertyIntVisible)));
            Assert.IsNotNull(adapterA4.Methods.ByNameOrNull(nameof(aInner1.ToString)));
            // Inherited - no visibility attribute
            SubClassAInner1     aSubInner1 = new SubClassAInner1();
            WoopsaObjectAdapter adapterA5  = new WoopsaObjectAdapter(null, "a", aSubInner1,
                                                                     null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.None);

            Assert.IsNotNull(adapterA5.Properties.ByNameOrNull(nameof(aSubInner1.ExtraProperty)));
            Assert.IsNull(adapterA5.Properties.ByNameOrNull(nameof(aSubInner1.APropertyIntHidden)));
            Assert.IsNull(adapterA5.Properties.ByNameOrNull(nameof(aSubInner1.APropertyIntVisible)));
            Assert.IsNull(adapterA5.Methods.ByNameOrNull(nameof(aSubInner1.ToString)));
            // Inherited - visibility attribute
            SubClassAInner2     aSubInner2 = new SubClassAInner2();
            WoopsaObjectAdapter adapterA6  = new WoopsaObjectAdapter(null, "a", aSubInner2,
                                                                     null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.None);

            Assert.IsNotNull(adapterA6.Properties.ByNameOrNull(nameof(aSubInner2.ExtraProperty)));
            Assert.IsNull(adapterA6.Properties.ByNameOrNull(nameof(aSubInner2.APropertyIntHidden)));
            Assert.IsNotNull(adapterA6.Properties.ByNameOrNull(nameof(aSubInner2.APropertyIntVisible)));
            Assert.IsNotNull(adapterA6.Methods.ByNameOrNull(nameof(aSubInner2.ToString)));
            // Inner objects
            ClassA a1 = new ClassA();
            WoopsaObjectAdapter adapterA7 = new WoopsaObjectAdapter(null, "a", a1);
            var a1Inner1 = adapterA7.Items.ByNameOrNull(nameof(a1.Inner1));

            Assert.IsNotNull(a1Inner1);
            var a1Inner1Inner = a1Inner1.Items.ByNameOrNull(nameof(ClassAInner1.Inner)) as WoopsaObjectAdapter;

            Assert.IsNotNull(a1Inner1Inner);
            Assert.IsNotNull(a1Inner1Inner.Properties.ByNameOrNull(
                                 nameof(a1.Inner1.Inner.APropertyVisible)));
            Assert.IsNotNull(a1Inner1Inner.Properties.ByNameOrNull(
                                 nameof(a1.Inner1.Inner.APropertyString)));
            Assert.IsNull(a1Inner1Inner.Properties.ByNameOrNull(
                              nameof(a1.Inner1.Inner.APropertyHidden)));
            Assert.IsNull(a1Inner1Inner.Methods.ByNameOrNull(
                              nameof(a1.Inner1.Inner.ToString)));
            // Update innerObject, retrieve again the adapter and proceeds new Checks
            a1.Inner1     = new SubClassAInner2();
            a1Inner1Inner = a1Inner1.Items.ByNameOrNull(nameof(ClassAInner1.Inner)) as WoopsaObjectAdapter;
            Assert.IsNotNull(a1Inner1Inner.Methods.ByNameOrNull(
                                 nameof(a1.Inner1.Inner.ToString)));
        }
 public void TestWoopsaObjectAdapterVisibility()
 {
     ClassAInner1 aInner1 = new ClassAInner1();
     // DefaultIsvisible false
     WoopsaObjectAdapter adapterA1 = new WoopsaObjectAdapter(null, "a", aInner1,
         null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.None);
     Assert.IsNull(adapterA1.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
     Assert.IsNull(adapterA1.Properties.ByNameOrNull(nameof(aInner1.APropertyIntHidden)));
     Assert.IsNotNull(adapterA1.Properties.ByNameOrNull(nameof(aInner1.APropertyIntVisible)));
     Assert.IsNull(adapterA1.Methods.ByNameOrNull(nameof(aInner1.ToString)));
     // DefaultIsvisible true
     WoopsaObjectAdapter adapterA2 = new WoopsaObjectAdapter(null, "a", aInner1,
         null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.DefaultIsVisible);
     Assert.IsNotNull(adapterA2.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
     Assert.IsNull(adapterA2.Methods.ByNameOrNull(nameof(aInner1.ToString)));
     // DefaultVisibility
     WoopsaObjectAdapter adapterA3 = new WoopsaObjectAdapter(null, "a", aInner1);
     Assert.IsNotNull(adapterA3.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
     Assert.IsNull(adapterA3.Properties.ByNameOrNull(nameof(aInner1.APropertyIntHidden)));
     Assert.IsNotNull(adapterA3.Properties.ByNameOrNull(nameof(aInner1.APropertyIntVisible)));
     Assert.IsNull(adapterA3.Methods.ByNameOrNull(nameof(aInner1.ToString)));
     // Visiblity All
     WoopsaObjectAdapter adapterA4 = new WoopsaObjectAdapter(null, "a", aInner1,
         null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.All);
     Assert.IsNotNull(adapterA4.Properties.ByNameOrNull(nameof(aInner1.APropertyInt)));
     Assert.IsNull(adapterA4.Properties.ByNameOrNull(nameof(aInner1.APropertyIntHidden)));
     Assert.IsNotNull(adapterA4.Properties.ByNameOrNull(nameof(aInner1.APropertyIntVisible)));
     Assert.IsNotNull(adapterA4.Methods.ByNameOrNull(nameof(aInner1.ToString)));
     // Inherited - no visibility attribute
     SubClassAInner1 aSubInner1 = new SubClassAInner1();
     WoopsaObjectAdapter adapterA5 = new WoopsaObjectAdapter(null, "a", aSubInner1,
         null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.None);
     Assert.IsNotNull(adapterA5.Properties.ByNameOrNull(nameof(aSubInner1.ExtraProperty)));
     Assert.IsNull(adapterA5.Properties.ByNameOrNull(nameof(aSubInner1.APropertyIntHidden)));
     Assert.IsNull(adapterA5.Properties.ByNameOrNull(nameof(aSubInner1.APropertyIntVisible)));
     Assert.IsNull(adapterA5.Methods.ByNameOrNull(nameof(aSubInner1.ToString)));
     // Inherited - visibility attribute
     SubClassAInner2 aSubInner2 = new SubClassAInner2();
     WoopsaObjectAdapter adapterA6 = new WoopsaObjectAdapter(null, "a", aSubInner2,
         null, null, WoopsaObjectAdapterOptions.None, WoopsaVisibility.None);
     Assert.IsNotNull(adapterA6.Properties.ByNameOrNull(nameof(aSubInner2.ExtraProperty)));
     Assert.IsNull(adapterA6.Properties.ByNameOrNull(nameof(aSubInner2.APropertyIntHidden)));
     Assert.IsNotNull(adapterA6.Properties.ByNameOrNull(nameof(aSubInner2.APropertyIntVisible)));
     Assert.IsNotNull(adapterA6.Methods.ByNameOrNull(nameof(aSubInner2.ToString)));
     // Inner objects
     ClassA a1 = new ClassA();
     WoopsaObjectAdapter adapterA7 = new WoopsaObjectAdapter(null, "a", a1);
     var a1Inner1 = adapterA7.Items.ByNameOrNull(nameof(a1.Inner1));
     Assert.IsNotNull(a1Inner1);
     var a1Inner1Inner = a1Inner1.Items.ByNameOrNull(nameof(ClassAInner1.Inner)) as WoopsaObjectAdapter;
     Assert.IsNotNull(a1Inner1Inner);
     Assert.IsNotNull(a1Inner1Inner.Properties.ByNameOrNull(
         nameof(a1.Inner1.Inner.APropertyVisible)));
     Assert.IsNotNull(a1Inner1Inner.Properties.ByNameOrNull(
         nameof(a1.Inner1.Inner.APropertyString)));
     Assert.IsNull(a1Inner1Inner.Properties.ByNameOrNull(
         nameof(a1.Inner1.Inner.APropertyHidden)));
     Assert.IsNull(a1Inner1Inner.Methods.ByNameOrNull(
         nameof(a1.Inner1.Inner.ToString)));
     // Update innerObject, retrieve again the adapter and proceeds new Checks
     a1.Inner1 = new SubClassAInner2();
     a1Inner1Inner = a1Inner1.Items.ByNameOrNull(nameof(ClassAInner1.Inner)) as WoopsaObjectAdapter;
     Assert.IsNotNull(a1Inner1Inner.Methods.ByNameOrNull(
         nameof(a1.Inner1.Inner.ToString)));
 }