void Prepare(string code, string baseClassName, string derivedClassName) { cu = helper.Parse("a.cs", code); objectClass = cu.ProjectContent.GetClass("System.Object", 0); Assert.That(objectClass, Is.Not.Null, "Could not find class for System.Object in project content."); baseClass = cu.ProjectContent.GetClass(baseClassName, 0); Assert.That(baseClass, Is.Not.Null, "Could not find class for '" + baseClassName + "' in project content."); derivedClass = cu.ProjectContent.GetClass(derivedClassName, 0); Assert.That(derivedClass, Is.Not.Null, "Could not find class for '" + derivedClassName + "' in project content."); }
/// <summary> /// ensures that the custom assertions in this test fixture are working properly /// </summary> public void SanityCheckTest() { ICompilationUnit cu = helper.Parse(ITestClass.FileName, ITestClass.FileContent); Assert.That(cu.Classes, Has.Count.EqualTo(1)); IClass c = cu.Classes[0]; Assert.That(c.ClassType, Is.EqualTo(ClassType.Interface)); Assert.That(c.BaseTypes, Has.Count.EqualTo(0)); Assert.That(c.Attributes, Has.Count.EqualTo(0)); Assert.That(c.Events, Has.Count.EqualTo(1)); Assert.That(c.Methods, Has.Count.EqualTo(2)); { IMethod m = c.Methods[0]; Assert.That(m.Name, Is.EqualTo("GetRange")); Assert.That(m.Parameters, Has.Count.EqualTo(1)); Assert.That(m, HasEmpty.MethodBody); m = c.Methods[1]; Assert.That(m.Name, Is.EqualTo("MultiplyBy5")); Assert.That(m.Parameters, Has.Count.EqualTo(2)); Assert.That(m, HasEmpty.MethodBody); } Assert.That(c.Properties, Has.Count.EqualTo(3)); { IProperty p = c.Properties[0]; Assert.That(p.Name, Is.EqualTo("Name")); Assert.That(p.CanGet, Is.True); Assert.That(p, HasEmpty.GetRegion); Assert.That(p.CanSet, Is.False); p = c.Properties[1]; Assert.That(p.Name, Is.EqualTo("Property")); Assert.That(p.CanGet, Is.True); Assert.That(p, HasEmpty.GetRegion); Assert.That(p.CanSet, Is.True); Assert.That(p, HasEmpty.SetRegion); p = c.Properties[2]; Assert.That(p.Name, Is.EqualTo("Configure")); Assert.That(p.CanGet, Is.False); Assert.That(p.CanSet, Is.True); Assert.That(p, HasEmpty.SetRegion); } }