Пример #1
0
        public void TestClassFullName()
        {
            Namespace n = new Namespace(null, null);
            n.Name = "foo";

            Class c = new Class(null, null);
            c.UnqualifiedName = "bar";
            Console.WriteLine(c.GetQualifiedName());
            Assert.AreEqual("foo", n.Name, "namespace name1");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name1");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name1");
            Assert.AreEqual("bar", c.GetQualifiedName(), "class full name1");

            c.ParentExpression = n;
            Assert.AreEqual("foo", n.Name, "namespace name2");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name2");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name2");
            Assert.AreEqual("foo.bar", c.GetQualifiedName(), "class full name2");

            c.ParentExpression = new Expression(null, null);
            Assert.AreEqual("foo", n.Name, "namespace name3");
            Assert.AreEqual("foo", n.GetFullName(), "namespace full name3");
            Assert.AreEqual("bar", c.UnqualifiedName, "class name3");
            Assert.AreEqual("bar", c.GetQualifiedName(), "class full name3");
        }
Пример #2
0
 /* All classes produced during a test should be
  * valiated with this method. Scenarios to test:
  *
  * Class with body
  * Name
  * Accessibility
  * Generic parameters
  * Class inheritance
  * Interface inheritance
  * Final (sealed)
  * Module (static class)
  * Correct parent expression (root, namespace, class, or module)
  * If a compiler error is supposed to be thrown, validate it is the correct error.
  *
  * */
 public static void ValidateClass(Class c, 
     Expression parentExpression, 
     string name, 
     string fullName, 
     Accessibility access, 
     bool module, 
     bool final,
     bool partial,
     bool isAbstract,
     bool isStruct)
 {
     // Validate the class
     Assert.AreEqual(name, c.UnqualifiedName, "class Name");
     Assert.AreEqual(module, c.IsModule, "IsModule");
     Assert.AreEqual(fullName, c.GetQualifiedName(), "FullName");
     Assert.AreEqual(c.Accessibility, access, "Accessibility");
     Assert.AreEqual(parentExpression, c.ParentExpression, "ParentExpresion");
     Assert.AreEqual(final, c.IsFinal, "IsFinal");
     Assert.AreEqual(partial, c.IsPartial, "IsPartial");
     Assert.AreEqual(isAbstract, c.IsAbstract, "IsAbstract");
     Assert.AreEqual(isStruct, c.IsStruct);
 }