///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  BVTCIMv2.CPP
//
//
//  Copyright (c)2000 Microsoft Corporation, All Rights Reserved
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <bvt.h>


#define NO_ERRORS_EXPECTED       FALSE,__FILE__,__LINE__
#define ERRORS_CAN_BE_EXPECTED   TRUE,__FILE__,__LINE__
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 200
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_OpenNamespace()
{
    //==========================================================================
    // Open CIMV2 namespace
    //==========================================================================
    int nRc = FATAL_ERROR;
    IWbemServices   * pNamespace    = NULL;
    CAutoDeleteString sNamespace;

    if( g_Options.GetOptionsForAPITest(sNamespace, APITEST200) )
    {
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace.GetPtr(),FALSE);
	    // =====================================================================
        //  Release the pointers
	    // =====================================================================
        SAFE_RELEASE_PTR(pNamespace);
    }
    return nRc;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 201
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_EnumerateClasses()
{
    int nRc = FATAL_ERROR;
    //==========================================================================
    // Get class enumerator for the namespace to get list of classes
    //==========================================================================
    CAutoDeleteString sNamespace;

    if( g_Options.GetOptionsForAPITest(sNamespace, APITEST200) )
    {
        IWbemServices   * pNamespace    = NULL;
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace.GetPtr(),FALSE);

        if( SUCCESS == nRc )
        {
            // =============================================================
            //  Get the list of classes to make sure they are in namespace
            // =============================================================
            CAutoDeleteString sClassesToCompare;
            if( g_Options.GetOptionsForAPITest( sClassesToCompare, APITEST201 ) )
            {
                // =========================================================
                // Make sure those classes are in the namespace
                // =========================================================
                nRc = EnumerateClassesAndCompare(sClassesToCompare, pNamespace, sNamespace.GetPtr());
            }
        }
	    // =====================================================================
        //  Release the pointers
	    // =====================================================================
        SAFE_RELEASE_PTR(pNamespace);
    }
    return nRc;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 202
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_EnumerateInstances()
{
    int nRc = FATAL_ERROR;
    //==========================================================================
    // Get instance enumerator for classes Win32_logicalDisk,  Win32_Process 
    //==========================================================================
    IWbemServices   * pNamespace    = NULL;
    CAutoDeleteString sNamespace;

    if( g_Options.GetOptionsForAPITest(sNamespace, APITEST200) )
    {
        IWbemServices   * pNamespace    = NULL;
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace.GetPtr(),FALSE);
        if( SUCCESS == nRc )
        {
            // =============================================================
            //  Get the list of classes to get instances for
            // =============================================================
            CAutoDeleteString sInstanceList;
            CAutoDeleteString sInstanceCompareList;

            if( g_Options.GetOptionsForAPITest( sInstanceList, sInstanceCompareList, APITEST202 ) )
            {
                // =========================================================
                // Make sure those instances are in the namespace
                // =========================================================
                nRc = EnumerateInstancesAndCompare(pNamespace, sInstanceList, sInstanceCompareList, sNamespace.GetPtr());
            }
        }
	    // =====================================================================
        //  Release the pointers
	    // =====================================================================
        SAFE_RELEASE_PTR(pNamespace);
    }
    return nRc;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 203
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_GetObjects()
{
    int nRc = FATAL_ERROR;
    //==========================================================================
    // Get classes/instances using path of the object
    //==========================================================================
    CAutoDeleteString sNamespace;

    if( g_Options.GetOptionsForAPITest(sNamespace, APITEST200) )
    {
        IWbemServices   * pNamespace    = NULL;
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace.GetPtr(),FALSE);

        if( SUCCESS == nRc )
        {
            // =============================================================
            //  Get the list of objexts to get
            // =============================================================
            CAutoDeleteString sObjects;
            if( g_Options.GetOptionsForAPITest( sObjects, APITEST203 ) )
            {
                // =========================================================
                // Get the requested objects
                // =========================================================
                nRc = GetSpecificObjects(sObjects, pNamespace, sNamespace.GetPtr());
            }
        }
	    // =====================================================================
        //  Release the pointers
	    // =====================================================================
        SAFE_RELEASE_PTR(pNamespace);
    }

    return nRc;   
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 204
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_ExecuteQueries()
{
    int nRc = FATAL_ERROR;
// Execute Association/Reference queries
    return nRc;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 205
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_EnumerateClassAMethods()
{
    int nRc = FATAL_ERROR;
// Enumerate methods for a class/instance.
    return nRc;
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 206
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_EnumerateInstanceMethods()
{
    int nRc = FATAL_ERROR;
// Enumerate methods for a class/instance.
    return nRc;
}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************************************************
//  Test 207
//*****************************************************************************************************************
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int CIMV2_ExecuteMethod()
{
    int nRc = FATAL_ERROR;
// Execute a method on one of the instance say Terminate method on Win32_process and check if the instance is removed.
    return nRc;
}

