Dashboard > GreenPepper Seeds > Home > Object Graph Navigation (.NET)
  GreenPepper Seeds Log In View a printable version of the current page.  
  Object Graph Navigation (.NET)
Added by Laurent Cobos, last edited by Laurent Cobos on Jun 27, 2007
Labels: 

 GreenPepperAnonymous access is denied. You must log in to use GreenPepper.

Object Graph Navigation

Import
Greenpepper.Ogn

Supports object graph navigation to help us access properties inside the domain's objects without having to build fixtures.

We must priviligied an existing method in the fixture. If no method found in the fixture, start searching a matching method under the graph representation of underlying domain objects.

Example

 
public class SomeFixtureUsingEmploye
{
   public Employe employe = new Employe(new Name("Charles", "Smith"));

   // case 1
   public string EmployeeNameFirst()
   {
       get { return employee.Name.First; }
   }

   // case 2
   public Name EmployeeName 
   {
       get { return employee.Name; }
   }
}

public class Employe
{
   public Name name;

   public Employe (Name name) 
   { 
       this.name = name;
   }

   public Name Name
   {
       get { return name; }
       set { name = value; }
   }

   // case 3
   public string NameFirst
   {
       get { return name.First; }
   }
}

public class Name
{
   private string first;
   private string last;

   public Name (string first, string last) 
   { 
       this.first = first;
       this.last = last;
   }

   // case 4
   public string First 
   {
       get { return first; } 
       set { first = value; }
   }

   public string Last
   {
       get { return last; }
       set { last = value; }
   }
}

Unable to render embedded object: File (ObjectGraphNavigation-EmployeeNameFirst.png) not found.

list of object graph navigation resolution for header Employee Name First
target method name
nothing EmployeeNameFirst
EmployeeName First
Employee NameFirst
Employee.Name First

Another case with more depth :

list of object graph navigation resolution for header a b c d
target method name
nothing abcd
abc d
ab cd
ab.c d
a bcd
a.bc d
a.b cd
a.b.c d

Example

This example shows the call of all methods involve in resolving the object graph name.
(Class # method)

rule for object graph navigation example fixture
object graph method name ?
employee name first Fixture#EmployeeNameFirst
thejob title short description Fixture#TheJob, Job#TitleShortDescription
thejob title long description Fixture#TheJob, Job#Title, Title#LongDescription
thejob status id Fixture#TheJob, Job#Status, Status#Id

Initial request

Support of OGNL expression inside GreenPepper examples.

Fixtureless

Supports OGNL to help us access properties inside the domain's objects without having to build fixtures.

Example

Given the following class:

 
public class Employe
{
   public string firstName;
   private string lastName;

   public Employe (string firstName, string lastName) 
   { 
       this.firstName = firstName;
       this.lastName = lastName;
   }

   public string LastName
   {
       get { return lastName; }
       set { lastName = value; }
   }

   public String FullName() { return firstName + ", " + lastName;}
}


public class SomeFixtureUsingEmploye
{
   public Employe employe = new Employe("Charles", "Smith");
}

I want to be able to access the employe fullName without having to write a method
public string EmployeFullName() {return employe.FullName();} in my fixture.

DEMONSTRATION LICENSE - This Confluence site is for demonstration purposes only. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.4.3 Build:#705 Mar 21, 2007) - Bug/feature request - Contact Administrators