Example #1
0
        static void RunTests(ServerBase <object> rem)
        {
            Assert.AreEqual(42, rem.TestIface <int>(42),
                            "#1 calling TestIface on object instance");

            Assert.AreEqual(42, rem.TestVirt <int>(42),
                            "#2 calling TestVirt");

            ITest i = rem;

            Assert.AreEqual(42, i.TestIface <int>(42),
                            "#3 calling TestIface on interface");

            Assert.AreEqual(42, i.TestDirectIfaceImpl(42),
                            "#4 calling TestDirectIfaceImp");

            INested cao = rem.GetNested();

            Assert.AreEqual(42, cao.Test(),
                            "#5a calling INested.Test ()");

            Assert.AreEqual(42 + 500, cao.Test(42),
                            "#5 calling INested.Test (int)");

            Assert.AreEqual(42, cao.Test(21, 21),
                            "#6 calling INested.Test (int, int)");

            Assert.AreEqual(42, cao.Test <int> (42),
                            "#7 calling INested.Test<V>");

            Assert.AreEqual(0, cao.Test <int, string> (42, "bar"),
                            "#8 calling INested.Test<V, T>");

            cao = rem.GetNestedMbr();
            Assert.AreEqual(42, cao.Test(),
                            "#9a calling INested.Test ()");

            Assert.AreEqual(42 + 500, cao.Test(42),
                            "#9 calling INested.Test (int)");

            Assert.AreEqual(42, cao.Test(21, 21),
                            "#10 calling INested.Test (int, int)");

            Assert.AreEqual(42, cao.Test <int> (42),
                            "#11 calling INested.Test<V>");

            Assert.AreEqual(0, cao.Test <int, string> (42, "bar"),
                            "#12 calling INested.Test<V, T>");
        }
Example #2
0
        public static string Generate(params object[] elements)
        {
            string doc = "";

            foreach (object obj in elements)
            {
                ITagged myTaggedObject = obj as ITagged;
                INested myNestedObject = obj as INested;

                if (myNestedObject is null || myTaggedObject is null) // obj is of raw information type (or non nested decorator). no further recursion possible -> add & continue
                {
                    doc += obj;
                    continue;
                }
                doc += $"\n{myTaggedObject.TagId}" + Generate(myNestedObject.Elements) + $"\n{myTaggedObject.TagId[..1]}/{myTaggedObject.TagId[1..]}";// Recursive function call for nested elements