/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/**
 *
 * @fileoverview spec definition test runner for container compliance
 */
function SpecDefSuite() {
  this.name = 'Opensocial spec 0.7 Definition';
  this.id = 'SPEC-DEF-SUITE';
  this.tests = [
    { name: 'Opensocial spec 0.7 Definition',
      id: 'SPEC-DEF-TEST',
      priority: Test.PRIORITY.P0,
      description: 'Checks if namespaces, objects, enums and apis of OPEN-' +
          'SOCIAL SPEC 0.7 defined or not. Failures shows not defined items.',
      run: function(context, callback, result) {
        var totalObjects = 0;
        var notImplementedCount = 0;
        for (var feature in openSocial0_7.features) {
          for (var i = 0; i < openSocial0_7.features[feature].length; i++) {
            totalObjects++;
            var objectOptions =
                Helper.getObjectOptions(openSocial0_7.features[feature][i]);
            var implemented = Assert.assertEquals(objectOptions,
                openSocial0_7.features[feature][i]);
            if (!implemented) {
              notImplementedCount++;
            }
            result.addSubResult(feature, Assert.assertEquals,
                objectOptions, openSocial0_7.features[feature][i]);
          }
        }
        result.addSubResult(feature, Assert.assertEquals, notImplementedCount,
            0);
        Helper.logIntoResult(result,
            '***  Total objects verified: ' + totalObjects + ' :',
            'Not defined: ' + notImplementedCount + '  ***');
        callback(result);
      }
    }
  ]
};
