///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//  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;
    CHString sNamespace;

    if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 200) )
    {
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, WPTR sNamespace,FALSE,fCompareResults);
	    // =====================================================================
        //  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
    //==========================================================================
    CHString sNamespace;

    if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 200) )
    {
        IWbemServices   * pNamespace    = NULL;
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, WPTR sNamespace,FALSE,fCompareResults);

        if( SUCCESS == nRc )
        {
            // =============================================================
            //  Get the list of classes to make sure they are in namespace
            // =============================================================
            CHString sClassesToCompare;
            if( g_Options.GetSpecificOptionForAPITest( L"NAMESPACE",sClassesToCompare, 201 ) )
            {
                // =========================================================
                // Make sure those classes are in the namespace
                // =========================================================
                nRc = EnumerateClassesAndCompare(sClassesToCompare, 201,pNamespace,  (WCHAR*)((const WCHAR*)sNamespace));
            }
        }
	    // =====================================================================
        //  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;
    CHString sNamespace;

    if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 200) )
    {
        IWbemServices   * pNamespace    = NULL;
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace,FALSE,fCompareResults);
        if( SUCCESS == nRc )
        {
            // =============================================================
            //  Get the list of classes to get instances for
            // =============================================================
            CHString sInstanceList;
            CHString sInstanceCompareList;

            if( g_Options.GetSpecificOptionForAPITest( L"INSTANCES",sInstanceList, 202 ) )
            {
                 // =========================================================
                 //  Get the enumeration flags
                 // =========================================================
                 ItemList FlagList;
                 nRc = GetFlags(202, FlagList);
                 if( SUCCESS == nRc )
                 {
                     for( int i = 0; i < FlagList.Size(); i++ )
                     {
                         ItemInfo * p = FlagList.GetAt(i);
                        // ===================================================
                        // Make sure those instances are in the namespace
                        // ===================================================
                        nRc = GetInstanceAndCompare(pNamespace, p->dwFlags, sInstanceList, 202, (WCHAR*)((const WCHAR*) sNamespace));
                     }
                 }
            }
        }
	    // =====================================================================
        //  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
    //==========================================================================
    CHString sNamespace;

    if( g_Options.GetSpecificOptionForAPITest(L"NAMESPACE",sNamespace, 203) )
    {
        IWbemServices   * pNamespace    = NULL;
	    // =====================================================================
        //  Open the namespace
	    // =====================================================================
        nRc = OpenNamespaceAndKeepOpen( &pNamespace, sNamespace,FALSE,fCompareResults);

        if( SUCCESS == nRc )
        {
            // =============================================================
            //  Get the list of objexts to get
            // =============================================================
            CHString sObjects;
            if( g_Options.GetSpecificOptionForAPITest(L"LIST", sObjects, 203 ) )
            {
                // =========================================================
                // Get the requested objects
                // =========================================================
                nRc = GetSpecificObjects(sObjects, pNamespace, 203, (WCHAR*)((const WCHAR*)sNamespace));
            }
        }
	    // =====================================================================
        //  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;
}

