/** \file
 *
 *  Contains unit tests for the Universal classes
 *
 *  Copyright (c) 2013 MBARI
 *  MBARI Proprietary Information.  All Rights Reserved
 */

#ifndef _SCRATCHPAD_TEST_H
#define _SCRATCHPAD_TEST_H

#include "component/TestAsyncComponent.h"
#include "data/DataReader.h"
#include "data/DataWriter.h"

#include <cxxtest/TestSuite.h>

/**
 *  Unit tests for the DataReader and DataWriter classes using scratchpad variables

 *  \ingroup data
 */
class Scratchpad_Test : public CxxTest::TestSuite
{
public:

    /// Test Scratchpad Read & Write
    void testScratchpad( void )
    {
        TestAsyncComponent testComponent( "Scratchpad_TestComponent" );
        ScratchpadURI sp_test1( "sp_test1", Units::NONE );

        DataReader* sp_test1_reader = testComponent.newDataReader( sp_test1 );

        const double sp_test1_test( 99 );
        double sp_test1_value;
        TS_ASSERT( !sp_test1_reader->read( Units::NONE, sp_test1_value ) );

        DataWriter* sp_test1_writer = testComponent.newDataWriter( sp_test1 );
        TS_ASSERT( sp_test1_writer->write( Units::NONE, sp_test1_test ) );

        TS_ASSERT( sp_test1_reader->read( Units::NONE, sp_test1_value ) );

        TS_ASSERT_EQUALS( sp_test1_value, sp_test1_test );
    }
};

#endif // _SCRATCHPAD_TEST_H
