//**************************************************************************
//
//
//                       National Institute Of Standards and Technology
//                                    DTS Version 1.0
//         
//                                   NodeList Interface
//**************************************************************************

function NodeList()
{
   var tests = new Array (core0001N(), core0002N(), core0003N(),core0004N(),
                core0005N(), core0006N(), core0007N(), core0008N(),
                core0009N());
   return tests;
}

//------------------------ test case core-0001N ------------------------
//
// Testing feature - The items in the list are accessible via an integral
//                   index starting from zero. (index equal 0)
//
// Testing approach - Create a list of all the children elements of the
//                    third employee and access its first child by using
//                    an index of 0.  This should result in "employeeId"
//                    being selected.  Further we evaluate its content
//                    (by examining its "nodeName" attribute) to ensure 
//                    the proper element was accessed.
//
// Semantic Requirements: 1
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0001N()
 {
   var computedValue = "";
   var expectedValue = "employeeId";
   var employeeId = "";
   var testNode = "";

   results = new testResults("Core0001N");

   results.description = "The elements in the list are accessible via an "+
                         "integral index starting from 0 (this test checks "+
                         "for index equal to 0).";
//
// Retrieve targeted data.
//
      testNode = new nodeObject(THIRD); 
      employeeId = testNode.subNodes(FIRST); 
      computedValue = employeeId.nodeName;
//
// Write out results 
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0001N --------------------------
//
//--------------------------- test case core-0002N ---------------------------
//
// Testing feature - The items in the list are accessible via an integral
//                   index starting from zero. (index not equal 0)
//
// Testing approach - Create a list of all the children elements of the
//                    third employee and access its fourth child by 
//                    using an index of 3.  This should result in "salary"
//                    being selected.  Further we evaluate its "nodeName"
//                    attribute to ensure the proper element was accessed.
//
// Semantic Requirements: 1
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0002N()
 {
   var computedValue = "";
   var expectedValue = "salary";
   var salary = "";
   var testNode = "";

   results = new testResults("Core0002N");

   results.description = "The elements in the list are accessible via an "+
                         "integral index starting from 0 (this test checks "+
                         "for index not equal 0).";
//
//  Retrieve targeted data.
//
      testNode = new nodeObject(THIRD); 
      salary = testNode.subNodes(FOURTH);
      computedValue = salary.nodeName;
//
//    Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0002N --------------------------
//
//--------------------------- test case core-0003N ---------------------------
//
// Testing feature - The "item(index)" method returns the indexth item 
//                   in the collection.
//
// Testing approach - Create a list of all the Element children of the
//                    third employee and access its first child by invoking 
//                    the "item(index)" method with index = 0.  This should 
//                    cause the method to return the "employeeId" child.
//                    Further we evaluate the returned item's "nodeName" 
//                    attribute to ensure the correct item was returned. 
//          
// Semantic Requirements: 2 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0003N()
 {
   var computedValue = "";
   var expectedValue = "employeeId";
   var employeeId = "";
   var testNode = "";

    results = new testResults("Core0003N");

    results.description = "The \"item(index)\" method returns the indexth "+
                          "item in the collection (return first item).";
//
// Retrieve targeted data.
//
      testNode = new nodeObject(THIRD)
      employeeId = testNode.subNodes.item(FIRST);
      computedValue = employeeId.nodeName;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0003N --------------------------
//
//--------------------------- test case core-0004N ---------------------------
//
// Testing feature - The "item(index)" method returns the indexth item 
//                   in the collection.
//
// Testing approach - Create a list of all the Element children of the
//                    third employee and access its first child by invoking
//                    the "item(index)" method with index equals to the last 
//                    item in the list.  This should cause the method to 
//                    return the "address" child.  Further we evaluate the
//                    returned item's "nodeName" attribute to ensure the 
//                    correct item was returned.
//
// Semantic Requirements: 2
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0004N()
 {
   var computedValue = "";
   var expectedValue = "address";
   var address = "";
   var testNode = "";

    results = new testResults("Core0004N");

    results.description = "The \"item(index)\" method returns the indxth "+
                          "item in the collection (return last item).";
//
// Retrieve targeted data.
//
      testNode = new nodeObject(THIRD);
      address = testNode.subNodes.item(SIXTH);
      computedValue = address.nodeName;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0004N --------------------------
//
//--------------------------- test case core-0005N ---------------------------
//
// Testing feature - If the index is greater than or equal to number of  
//                   nodes, the "item(index)" method returns null.
//
// Testing approach - Create a list of all the Element children of the third
//                    employee and then invoke its "item(index)" method with 
//                    index equal to 6 (the number of nodes in the list).  This
//                    should cause the method to return null.
//
// Semantic Requirements: 3 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0005N()
 {
   var computedValue = "";
   var expectedValue = null; 
   var testNode = "";

    results = new testResults("Core0005N");
  
    results.description = "The \"item(index)\" method returns null if the "+
                          "index is greater than or equal to the number of "+
                          "nodes (index = number of nodes).";
//
// invoke the "item(index)" method with index equal to the number of nodes
// in the list (6, count starts at zero).  It should return null.
//
      testNode = new nodeObject(THIRD);
      computedValue = testNode.subNodes.item(SEVENTH);
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0005N --------------------------
//
//--------------------------- test case core-0006N ---------------------------
//
// Testing feature - If the index is greater than or equal to number of
//                   nodes, the "item(index)" method returns null.
//
// Testing approach - Create a list of all the Element children of the third
//                    employee and then invoke the "item(index)" with index
//                    equal to 7 (index is greater than number of nodes).  
//                    This should cause the method to return null.
//
// Semantic Requirements: 3
//
// Last modification date - March 3, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0006N()
 {
  var computedValue = "";
  var expectedValue = null;
  var testNode = "";

   results = new testResults("Core0006N");

   results.description = "The \"item(index)\" method returns null if the "+ 
                         "index is greater than or equal to the number of "+
                         "nodes (index > number of nodes).";
//
// Retrieve targeted data.  All counts start from zero
//
      testNode = new nodeObject(THIRD);
      computedValue = testNode.subNodes.item(EIGHT);
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0006N --------------------------
//
//--------------------------- test case core-0007N ---------------------------
//
// Testing feature - The "length" attribute contains the number of items in
//                   the list.
//
// Testing approach - Create a list of all the Element children of the third
//                    employee and then access the "length" attribute.
//                    It should contain the value 6.
//
// Semantic Requirements: 4 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0007N()
 {
  var computedValue = "";
  var expectedValue = 6;
  var thirdEmployeeList = "";

   results = new testResults("Core0007N");

   results.description = "The \"length\" attribute contains the number of "+
                         "nodes in the list (non empty list).";
//
// retrieve the targeted data and access the "length" attribute. 
//
      testNode = new nodeObject(THIRD);
      computedValue = testNode.subNodes.length;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0007N --------------------------
//
//--------------------------- test case core-0008N ---------------------------
//
// Testing feature - The "length" attribute contains the number of items in
//                   the list (test for empty list).
//
// Testing approach - Create a list of all the children of the Text node 
//                    inside the first child o the third employee and
//                    then access its "length" attribute.  It should 
//                    contain the value 0.
//
// Semantic Requirements: 4
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0008N()
 {
  var computedValue = "";
  var expectedValue = 0;
  var testNode = "";
  var textNode = "";

   results = new testResults("Core0008N");

   results.description = "The \"length\" attribute contains the number of "+
                         "nodes in the list (test for empty list).";
//
// Access the targeted data and examine the "length" attribute of an
// empty list.
//
      testNode = new nodeObject(THIRD,FIRST);
      textNode = testNode.node.firstChild;
      computedValue = textNode.childNodes.length;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0008N --------------------------
//
//--------------------------- test case core-0009 ---------------------------
//
// Testing feature - The range of valid child nodes indices is 0 to length - 1.
// 
// Testing approach - Create a list of all the Element children of the 
//                    third employee and traverse the list from index
//                    0 to index length - 1.
//
// Semantic Requirements: 5 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
//----------------------------------------------------------------------------

 function core0009N()
 {
   var computedValue = "";
   var expectedValue = "employeeId name position salary gender address ";
   var lastIndex = 0;
   var listLength = 0;
   var testNode = "";

    results = new testResults("Core0009N");

    results.description = "The range of valid child nodes indices is 0 to "+
                          "length - 1.";
//
// Retrieve the targeted data and determine the length of the list.
//
      testNode =  new nodeObject(THIRD);
      listLength = testNode.subNodes.length; 
      lastIndex = listLength - 1;
//
// Traverse the list from 0 to length - 1.  All indices should be valid.
//
    for (var index = 0; index <= lastIndex; index++)
        computedValue += testNode.subNodes(index).nodeName+" ";
//
// Write out results. 
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0009N --------------------------